daf.typing.dense¶
The types here describe a dense 2D numpy.ndarray
matrices, which can be fetched from daf
.
Note
We actively prevent using the deprecated data type numpy.matrix
which is occasionally returned from some
operations, isinstance
of numpy.ndarray
, and behaves just differently enough from a normal numpy.ndarray
to cause subtle and difficult problems.
Data:
2-dimensional |
|
|
|
Functions:
|
Check whether some |
|
Assert that some |
|
Access the internal 2D |
|
Check whether some |
|
Assert that some |
|
Check whether some |
|
Assert that some |
- daf.typing.dense.Dense(*args, **kwargs)¶
2-dimensional
numpy
array (dense matrix) in eitherROW_MAJOR
orCOLUMN_MAJOR
layout.alias of
Union
[DenseInRows
,DenseInColumns
]
- daf.typing.dense.is_dense(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None, layout: Optional[_layouts.AnyMajor] = None) TypeGuard[Dense] [source]¶
Check whether some
data
is aDense
, 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.dense.be_dense(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[DenseInRows, DenseInColumns] [source]¶
Assert that some
data
is aDense
optionally only of somedtype
, optionally only of someshape
, optionally only of of a specificlayout
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.dense.as_dense(data: DenseInRows, *, force_copy: bool = False) DenseInRows [source]¶
- daf.typing.dense.as_dense(data: DenseInColumns, *, force_copy: bool = False) DenseInColumns
- daf.typing.dense.as_dense(data: SparseInRows, *, force_copy: bool = False) DenseInRows
- daf.typing.dense.as_dense(data: SparseInColumns, *, force_copy: bool = False) DenseInColumns
- daf.typing.dense.as_dense(data: spmatrix, *, force_copy: bool = False) Union[DenseInRows, DenseInColumns]
- daf.typing.dense.as_dense(data: FrameInRows, *, force_copy: bool = False) DenseInRows
- daf.typing.dense.as_dense(data: FrameInColumns, *, force_copy: bool = False) DenseInColumns
- daf.typing.dense.as_dense(data: Union[Sequence[Any], ndarray, _fake_sparse.spmatrix, Series, DataFrame], *, force_copy: bool = False) Union[DenseInRows, DenseInColumns]
Access the internal 2D
numpy
array, if possible; otherwise, or ifforce_copy
, return a copy of the 2D data as a 2Dnumpy
array.Accepts as input many data types that aren’t even a
Matrix
, such as nested lists (basically anything thatnumpy.array
can use to construct a 2D array).If the input is a
pandas.DataFrame
, this will only work if all the data elements in the frame has the same type.This will convert
pandas
strings (even if categorical) to propernumpy
strings.
- daf.typing.dense.DenseInRows¶
2-dimensional
numpy
array (dense matrix) inROW_MAJOR
layout.alias of
ndarray
- daf.typing.dense.is_dense_in_rows(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[DenseInRows] [source]¶
Check whether some
data
is aDenseInRows
, optionally only of somedtype
, optionally only of someshape
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.dense.be_dense_in_rows(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) DenseInRows [source]¶
Assert that some
data
is aDenseInRows
, 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.dense.DenseInColumns¶
2-dimensional
numpy
array (dense matrix) inCOLUMN_MAJOR
layout.alias of
ndarray
- daf.typing.dense.is_dense_in_columns(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[DenseInColumns] [source]¶
Check whether some
data
is aDenseInColumns
, optionally only of somedtype
, optionally only of someshape
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.dense.be_dense_in_columns(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) DenseInColumns [source]¶
Assert that some
data
is aDenseInColumns
, 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
.