daf.typing.sparse¶
The types here describe a sparse compressed scipy.sparse.csr_matrix and scipy.sparse.csc_matrix data, which
can be fetched from daf.
In theory it should have been possible to store sparse data inside a pandas.DataFrame, but in practice this fails in
various ways, so don’t. When fetching data from daf, frames will alway contain dense (numpy.ndarray 2D)
data.
Note
Other sparse formats (e.g. scipy.sparse.coo_matrix) can’t be fetched from daf. This allows daf to ensure
that all fetched data is in either ROW_MAJOR or COLUMN_MAJOR layout, which greatly simplifies the code
accessing the data.
Data:
2D |
|
|
|
Functions:
|
Check whether some |
|
Assert that some |
|
Check whether some |
|
Assert that some |
|
Check whether some |
|
Assert that some |
- daf.typing.sparse.Sparse(*args, **kwargs)¶
2D
scipy.sparse.spmatrixin compressed layout.alias of
Union[SparseInRows,SparseInColumns]
- daf.typing.sparse.is_sparse(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None, layout: Optional[_layouts.AnyMajor] = None) TypeGuard[Sparse][source]¶
Check whether some
datais aSparse, optionally only of somedtype, optionally only of someshape, optionally only of somelayout.By default, checks that the data type is one of
ALL_DTYPES.
- daf.typing.sparse.be_sparse(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None, layout: Optional[AnyMajor] = None) Union[SparseInRows, SparseInColumns][source]¶
Assert that some
datais aSparseoptionally only of somedtype, optionally only of someshape, optionally of somelayout, and return it as such formypy.By default, checks that the data type is one of
ALL_DTYPES.
- daf.typing.sparse.SparseInRows¶
2D
scipy.sparse.spmatrixin CSR layout (that is,scipy.sparse.csr_matrix).alias of _fake_sparse.cs_matrix
- daf.typing.sparse.is_sparse_in_rows(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[SparseInRows][source]¶
Check whether some
datais aSparseInRows, optionally only of somedtype, optionally only of someshape.By default, checks that the data type is one of
ALL_DTYPES.
- daf.typing.sparse.be_sparse_in_rows(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) SparseInRows[source]¶
Assert that some
datais aSparseInRows, optionally only of somedtype, optionally only of someshape, and return it as such formypy.By default, checks that the data type is one of
ALL_DTYPES.
- daf.typing.sparse.SparseInColumns¶
2D
scipy.sparse.spmatrixin CSC layout (that is,scipy.sparse.csc_matrix).alias of _fake_sparse.cs_matrix
- daf.typing.sparse.is_sparse_in_columns(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[SparseInColumns][source]¶
Check whether some
datais aSparseInColumns, optionally only of somedtype, optionally only of someshape.By default, checks that the data type is one of
ALL_DTYPES.
- daf.typing.sparse.be_sparse_in_columns(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) SparseInColumns[source]¶
Assert that some
datais aSparseInColumns, optionally only of somedtype, optionally only of someshape, and return it as such formypy.By default, checks that the data type is one of
ALL_DTYPES.