Return an iterator over the rows of the data matrix :attr:`X`.

        Parameters
        ----------
        chunk_size
            Row size of a single chunk.
8119
def chunked_X(self, chunk_size: Optional[int] = None):
        
        if chunk_size is None:
            # Should be some adaptive code
            chunk_size = 6000
        start = 0
        n = self.n_obs
        for _ in range(int(n // chunk_size)):
            end = start + chunk_size
            yield (self.X[start:end], start, end)
            start = end
        if start < n:
            yield (self.X[start:n], start, n)
642616
def _compute_total_chunks(self, chunk_size):
        # type: (Descriptor, int) -> int
        
        try:
            return int(math.ceil(self._ase.size / chunk_size))
        except ZeroDivisionError:
            return 0
662886
def batched(iterable, size):
    
    length = len(iterable)
    for batch_start in range(0, length, size):
        yield iterable[batch_start:batch_start+size]
270159
def chunks(event_list, chunk_size):
    """"""
    for i in range(0, len(event_list), chunk_size):
        yield event_list[i:i + chunk_size]
1078548
def chunks(data, size):
    
    for i in range(0, len(data), size):
        yield data[i:i + size]
415701
def chunks(self, size=32, alignment=1):
        

        if (size % alignment) != 0:
            raise Error(
                'size {} is not a multiple of alignment {}'.format(
                    size,
                    alignment))

        address = self.address
        data = self.data

        # First chunk may be shorter than `size` due to alignment.
        chunk_offset = (address % alignment)

        if chunk_offset != 0:
            first_chunk_size = (alignment - chunk_offset)
            yield self._Chunk(address, data[:first_chunk_size])
            address += (first_chunk_size // self._word_size_bytes)
            data = data[first_chunk_size:]
        else:
            first_chunk_size = 0

        for offset in range(0, len(data), size):
            yield self._Chunk(address + offset // self._word_size_bytes,
                              data[offset:offset + size])
272128
def normalise_rows(matrix):
    

    lengths = np.apply_along_axis(np.linalg.norm, 1, matrix)
    if not (lengths > 0).all():
        # raise ValueError('Cannot normalise 0 length vector to length 1')
        # print(matrix)
        lengths[lengths == 0] = 1
    return matrix / lengths[:, np.newaxis]
771229
def rows_max(self, size=None, focus=False):
        
        if size is not None:
            ow = self._original_widget
            ow_size = self._get_original_widget_size(size)
            sizing = ow.sizing()
            if FIXED in sizing:
                self._rows_max_cached = ow.pack(ow_size, focus)[1]
            elif FLOW in sizing:
                self._rows_max_cached = ow.rows(ow_size, focus)
            else:
                raise RuntimeError('Not a flow/box widget: %r' % self._original_widget)
        return self._rows_max_cached
1212565
def sizes(count, offset=0, max_chunk=500):
    
    if count is None:
        chunk = max_chunk
        while True:
            yield chunk, offset
            offset += chunk
    else:
        while count:
            chunk = min(count, max_chunk)
            count = max(0, count - max_chunk)
            yield chunk, offset
            offset += chunk
1264353
def calculate_intervals(chunk_sizes):
        
        start_indexes = [sum(chunk_sizes[:i]) for i in range(0, len(chunk_sizes))]
        end_indexes = [sum(chunk_sizes[:i+1]) for i in range(0, len(chunk_sizes))]
        return tuple(zip(start_indexes, end_indexes))
805812
def _chunk_with_padding(self, iterable, n, fillvalue=None):
        ""
        # _chunk_with_padding('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
        args = [iter(iterable)] * n
        return zip_longest(*args, fillvalue=fillvalue)
777807
def list_to_rows(src, size):
    

    row = []
    for item in src:
        row.append(item)
        if len(row) == size:
            yield row
            row = []

    if row:
        yield row
815062
def columnCount(self, row=None):
        
        if row is not None:
            wholerow = self._segments[row]
            return len(wholerow)
        else:
            column_lengths = [len(x) for x in self._segments]
            return max(column_lengths)
981459
def chunk_list(items, size):
    
    size = max(1, size)
    return [items[i:i + size] for i in range(0, len(items), size)]
37963
def output_size(self) -> Tuple[Sequence[Shape], Sequence[Shape], Sequence[Shape], int]:
        ''''''
        return self._cell.output_size
1185741
def chunks(self, size=32, alignment=1):
        

        if (size % alignment) != 0:
            raise Error(
                'size {} is not a multiple of alignment {}'.format(
                    size,
                    alignment))

        for segment in self:
            for chunk in segment.chunks(size, alignment):
                yield chunk
1015754
def generate_chunks(data, chunk_size=DEFAULT_CHUNK_SIZE):
    """"""
    iterator = iter(repeated.getvalues(data))

    while True:
        chunk = list(itertools.islice(iterator, chunk_size))
        if not chunk:
            return

        yield chunk