Yield records from a slice index.
762603
def _iterslice(self, slice):
        """"""
        indices = range(*slice.indices(len(self._records)))
        if self.is_attached():
            rows = self._enum_attached_rows(indices)
            if slice.step is not None and slice.step < 0:
                rows = reversed(list(rows))
        else:
            rows = zip(indices, self._records[slice])

        fields = self.fields
        for i, row in rows:
            yield Record._make(fields, row, self, i)
306189
def iflatten(L):
    """"""
    for sublist in L:
        if hasattr(sublist, '__iter__'):
            for item in iflatten(sublist): yield item
        else: yield sublist
1048885
def get_chunks(Array, Chunksize):
    """"""
    for i in range(0, len(Array), Chunksize):
        yield Array[i:i + Chunksize]
232828
def getRecords(rids, dbid = @dbid, fieldNames = nil)
      records = []
      if rids.length > 0
        query = ""
        rids.each{|rid| query << "{'3'.EX.'#{rid}'}OR"}
        query[-2] = "" 
        fieldNames ||= getFieldNames(dbid)
        iterateRecords(dbid,fieldNames,query){|r| records << r }
      end
      if block_given?
        records.each{|rec|yield rec}
      else
        records  
      end        
   end
366506
def pieces(array, chunk_size):
        """"""
        for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size]
746625
def find_loops( record, index, stop_types = STOP_TYPES, open=None, seen = None ):
    """"""
    if open is None:
        open = []
    if seen is None:
        seen = set()
    for child in children( record, index, stop_types = stop_types ):
        if child['type'] in stop_types or child['type'] == LOOP_TYPE:
            continue
        if child['address'] in open:
            # loop has been found 
            start = open.index( child['address'] )
            new = frozenset( open[start:] )
            if new not in seen:
                seen.add(new)
                yield new
        elif child['address'] in seen:
            continue 
        else:
            seen.add( child['address'])
            open.append( child['address'] )
            for loop in find_loops( child, index, stop_types=stop_types, open=open, seen=seen ):
                yield loop 
            open.pop( -1 )
760622
def chunks(lista, size):
    """"""
    if not isinstance(lista, list):
        logger.error('Erron in chunks, arg introduced is not a list.', lista=lista)
        return lista

    for i in range(0, len(lista), size):
        yield lista[i:i + size]
276854
def get_records(self):
        
        self.close()
        with open(self.path, 'r') as filep:
            first_line = filep.readline().split(',')
            if first_line[0] != self.fields[0]:
                yield first_line

            for line in filep:
                yield line.split(',')
567975
def chunks(l, n):
    """"""
    if n:
        for i in xrange(0, len(l), n):
            yield l[i:i + n]
961099
def include_from_file(records, handle):
    
    ids = set(i.strip() for i in handle)

    for record in records:
        if record.id.strip() in ids:
            yield record
256171
def recarray(self):
        """"""
        return numpy.rec.fromrecords(self.records, names=self.names)
1337142
def iter_slices(string, slice_length):
    """"""
    pos = 0
    if slice_length is None or slice_length <= 0:
        slice_length = len(string)
    while pos < len(string):
        yield string[pos:pos + slice_length]
        pos += slice_length
369542
def _query_iterator(result, chunksize, columns, index_col=None,
                        coerce_float=True, parse_dates=None):
        """"""

        while True:
            data = result.fetchmany(chunksize)
            if not data:
                break
            else:
                yield _wrap_result(data, columns, index_col=index_col,
                                   coerce_float=coerce_float,
                                   parse_dates=parse_dates)
811605
def records_for_bulk_index(ids, batch_size = 1000)
      transaction do
        offset = 0
        ids.each_slice(batch_size) do |id_slice|
          records = where(:id => id_slice).all
          #yield records, offset
          yield where(:id => id_slice).all, offset
          offset += batch_size
        end
      end
    end
1246104
def batch(input_iter, batch_size=32):
  """"""
  input_iter = iter(input_iter)
  next_ = list(itertools.islice(input_iter, batch_size))
  while next_:
    yield next_
    next_ = list(itertools.islice(input_iter, batch_size))
582589
def from_records(cls, records):
        """"""
        if not records:
            return cls()
        labels = sorted(list(records[0].keys()))
        columns = [[rec[label] for rec in records] for label in labels]
        return cls().with_columns(zip(labels, columns))
1365681
def iter_rows(self, start=None, end=None):
        """"""
        start = start or 0
        end = end or self.nrows
        for i in range(start, end):
            yield self.iloc[i, :]