MatrixChunk
MatrixChunk()A block of the matrix, as compressed numpy arrays: consecutive rows (axis == "obs", CSR, every column) or consecutive genes (axis == "var", CSC, every row). The block is rows row_offset:row_offset + nrows by columns var_offset:var_offset + ncols.
The arrays take ownership of the buffers the reader decoded into, so there is no per-chunk copy. They are writable and outlive the chunk.
Attributes
| Name | Description |
|---|---|
| axis | "obs" for a block of rows (CSR), "var" for a block of genes (CSC). |
| data | (nnz,) values. |
| dtype | NumPy dtype name of data, e.g. "float32". |
| indices | (nnz,) uint32 column indices ("obs") or row indices ("var"). |
| indptr | uint64 pointers: (nrows + 1,) per row for "obs", |
| n_vars | Number of columns (features) of the full matrix. |
| ncols | Number of columns in this chunk. |
| nrows | Number of rows in this chunk. |
| row_offset | Index of the first row of this chunk in the full matrix. |
| var_offset | Index of the first column of this chunk in the full matrix. |
Methods
| Name | Description |
|---|---|
| to_scipy | The chunk as a scipy.sparse.csr_array ("obs") or |
to_scipy
MatrixChunk.to_scipy()The chunk as a scipy.sparse.csr_array ("obs") or csc_array ("var") of shape (nrows, ncols) that shares data and indices with this chunk. scipy wants signed indices of one dtype: indices is viewed as int32 (same bits, never negative) and indptr is cast to int32, a copy of only its few entries. Given an int64 indptr, scipy would upcast, and so copy, indices.