def scan(self, *, items: np.ndarray = None, axis: int = None, layers: Iterable = None, key: str = None, batch_size: int = <NUM_LIT:8> * <NUM_LIT:64>) -> Iterable[Tuple[int, np.ndarray, loompy.LoomView]]:
if axis is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if layers is None:<EOL><INDENT>layers = self.layers.keys()<EOL><DEDENT>if layers == "<STR_LIT>":<EOL><INDENT>layers = ["<STR_LIT>"]<EOL><DEDENT>if (items is not None) and (np.issubdtype(items.dtype, np.bool_)):<EOL><INDENT>items = np.where(items)[<NUM_LIT:0>]<EOL><DEDENT>ordering: Union[np.ndarray, slice] = None<EOL>vals: Dict[str, loompy.MemoryLoomLayer] = {}<EOL>if axis == <NUM_LIT:1>:<EOL><INDENT>if key is not None:<EOL><INDENT>ordering = np.argsort(self.ra[key])<EOL><DEDENT>else:<EOL><INDENT>ordering = slice(None)<EOL><DEDENT>if items is None:<EOL><INDENT>items = np.fromiter(range(self.shape[<NUM_LIT:1>]), dtype='<STR_LIT:int>')<EOL><DEDENT>cols_per_chunk = batch_size<EOL>ix = <NUM_LIT:0><EOL>while ix < self.shape[<NUM_LIT:1>]:<EOL><INDENT>cols_per_chunk = min(self.shape[<NUM_LIT:1>] - ix, cols_per_chunk)<EOL>selection = items - ix<EOL>selection = selection[np.where(np.logical_and(selection >= <NUM_LIT:0>, selection < cols_per_chunk))[<NUM_LIT:0>]]<EOL>if selection.shape[<NUM_LIT:0>] == <NUM_LIT:0>:<EOL><INDENT>ix += cols_per_chunk<EOL>continue<EOL><DEDENT>for layer in layers:<EOL><INDENT>temp = self.layers[layer][:, ix:ix + cols_per_chunk]<EOL>temp = temp[ordering, :]<EOL>temp = temp[:, selection]<EOL>vals[layer] = loompy.MemoryLoomLayer(layer, temp)<EOL><DEDENT>lm = loompy.LayerManager(None)<EOL>for key, layer in vals.items():<EOL><INDENT>lm[key] = loompy.MemoryLoomLayer(key, layer)<EOL><DEDENT>view = loompy.LoomView(lm, self.ra[ordering], self.ca[ix + selection], self.row_graphs[ordering], self.col_graphs[ix + selection], filename=self.filename, file_attrs=self.attrs)<EOL>yield (ix, ix + selection, view)<EOL>ix += cols_per_chunk<EOL><DEDENT><DEDENT>elif axis == <NUM_LIT:0>:<EOL><INDENT>if key is not None:<EOL><INDENT>ordering = np.argsort(self.ca[key])<EOL><DEDENT>else:<EOL><INDENT>ordering = slice(None)<EOL><DEDENT>if items is None:<EOL><INDENT>items = np.fromiter(range(self.shape[<NUM_LIT:0>]), dtype='<STR_LIT:int>')<EOL><DEDENT>rows_per_chunk = batch_size<EOL>ix = <NUM_LIT:0><EOL>while ix < self.shape[<NUM_LIT:0>]:<EOL><INDENT>rows_per_chunk = min(self.shape[<NUM_LIT:0>] - ix, rows_per_chunk)<EOL>selection = items - ix<EOL>selection = selection[np.where(np.logical_and(selection >= <NUM_LIT:0>, selection < rows_per_chunk))[<NUM_LIT:0>]]<EOL>if selection.shape[<NUM_LIT:0>] == <NUM_LIT:0>:<EOL><INDENT>ix += rows_per_chunk<EOL>continue<EOL><DEDENT>for layer in layers:<EOL><INDENT>temp = self.layers[layer][ix:ix + rows_per_chunk, :]<EOL>temp = temp[:, ordering]<EOL>temp = temp[selection, :]<EOL>vals[layer] = loompy.MemoryLoomLayer(layer, temp)<EOL><DEDENT>lm = loompy.LayerManager(None)<EOL>for key, layer in vals.items():<EOL><INDENT>lm[key] = loompy.MemoryLoomLayer(key, layer)<EOL><DEDENT>view = loompy.LoomView(lm, self.ra[ix + selection], self.ca[ordering], self.row_graphs[ix + selection], self.col_graphs[ordering], filename=self.filename, file_attrs=self.attrs)<EOL>yield (ix, ix + selection, view)<EOL>ix += rows_per_chunk<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>
Scan across one axis and return batches of rows (columns) as LoomView objects

Args
----
items: np.ndarray
        the indexes [0, 2, 13, ... ,973] of the rows/cols to include along the axis
        OR: boolean mask array giving the rows/cols to include
axis: int
        0:rows or 1:cols
batch_size: int
        the chuncks returned at every element of the iterator
layers: iterable
        if specified it will batch scan only across some of the layers of the loom file
        if layers == None, all layers will be scanned
        if layers == [""] or "", only the default layer will be scanned
key:
        Name of primary key attribute. If specified, return the values sorted by the key

Returns
------
Iterable that yields triplets of (ix, indexes, view) where

ix: int
        first position / how many rows/cols have been yielded alredy
indexes: np.ndarray[int]
        the indexes with the same numbering of the input args cells / genes (i.e. ``np.arange(len(ds.shape[axis]))``)
        this is ``ix + selection``
view: LoomView
        a view corresponding to the current chunk