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:

Dense

2-dimensional numpy array (dense matrix) in either ROW_MAJOR or COLUMN_MAJOR layout.

DenseInRows(x)

DenseInColumns(x)

Functions:

is_dense(data, *[, dtype, shape, layout])

Check whether some data is a Dense, optionally only of some dtype, optionally only of some shape, optionally only of some layout.

be_dense(data, *[, dtype, shape, layout])

Assert that some data is a Dense optionally only of some dtype, optionally only of some shape, optionally only of of a specific layout, and return it as such for mypy.

as_dense()

Access the internal 2D numpy array, if possible; otherwise, or if force_copy, return a copy of the 2D data as a 2D numpy array.

is_dense_in_rows(data, *[, dtype, shape])

Check whether some data is a DenseInRows, optionally only of some dtype, optionally only of some shape.

be_dense_in_rows(data, *[, dtype, shape])

Assert that some data is a DenseInRows, optionally only of some dtype, optionally only of some shape, and return it as such for mypy.

is_dense_in_columns(data, *[, dtype, shape])

Check whether some data is a DenseInColumns, optionally only of some dtype, optionally only of some shape.

be_dense_in_columns(data, *[, dtype, shape])

Assert that some data is a DenseInColumns, optionally only of some dtype, optionally only of some shape, and return it as such for mypy.

daf.typing.dense.Dense(*args, **kwargs)

2-dimensional numpy array (dense matrix) in either ROW_MAJOR or COLUMN_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 a Dense, optionally only of some dtype, optionally only of some shape, optionally only of some layout.

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 a Dense optionally only of some dtype, optionally only of some shape, optionally only of of a specific layout, and return it as such for mypy.

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 if force_copy, return a copy of the 2D data as a 2D numpy array.

Accepts as input many data types that aren’t even a Matrix, such as nested lists (basically anything that numpy.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 proper numpy strings.

daf.typing.dense.DenseInRows

2-dimensional numpy array (dense matrix) in ROW_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 a DenseInRows, optionally only of some dtype, optionally only of some shape.

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 a DenseInRows, optionally only of some dtype, optionally only of some shape, and return it as such for mypy.

By default, checks that the data type is one of ALL_DTYPES.

daf.typing.dense.DenseInColumns

2-dimensional numpy array (dense matrix) in COLUMN_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 a DenseInColumns, optionally only of some dtype, optionally only of some shape.

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 a DenseInColumns, optionally only of some dtype, optionally only of some shape, and return it as such for mypy.

By default, checks that the data type is one of ALL_DTYPES.