daf.typing.unions¶
Union types used in the rest of the code.
These types capture important concepts that allow generic daf
functions to clearly express their intent. Due to to
limitations of mypy
, the existing type annotations in numpy
and the lack of type annotations in scipy.sparse
and pandas
, the Known...
types are too permissive, but the is_known...
/be_known...
functions do the
right thing.
Data:
"Any" data that can be used to construct "proper" 1D/2D data. |
|
Any 1D/2D data type that |
|
Any 1D data type that |
|
Any 2D data type that |
|
Any "proper" 1D/2D data type that |
|
Any "proper" 1D data type that |
|
Any "proper" 2D data type that |
|
Any "proper" |
|
Any "proper" |
Functions:
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
|
Assert that some |
- daf.typing.unions.AnyData(*args, **kwargs)¶
“Any” data that can be used to construct “proper” 1D/2D data.
We don’t distinguish between 1D and 2D data here, because one can use 2D-ish data with an axis of size 1 to construct 1D data (that is, a matrix with a single row can be used to construct a vector).
There are probably other alternatives that should be listed here, but this covers most usages.
alias of
Union
[Sequence
[Any
],ndarray
,_fake_sparse.spmatrix
,Series
,DataFrame
]
- daf.typing.unions.Known(*args, **kwargs)¶
Any 1D/2D data type that
daf
knows about.Due to
numpy.ndarray
type annotation limitations, we can’t usemypy
to ensure this is actually 1D/2D data.alias of
Union
[ndarray
,_fake_sparse.spmatrix
,Series
,DataFrame
]
- daf.typing.unions.is_known(data: Any) TypeGuard[Known] [source]¶
Assert that some
data
isKnown
(and actually 1D/2D data), and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.be_known(data: Any) Union[ndarray, _fake_sparse.spmatrix, Series, DataFrame] [source]¶
Assert that some
data
isKnown
(and actually 1D/2D data), and return it as such formypy
.
- daf.typing.unions.Known1D(*args, **kwargs)¶
Any 1D data type that
daf
knows about.Due to
numpy.ndarray
type annotation limitations, we can’t usemypy
to ensure this is actually 1D data.alias of
Union
[ndarray
,Series
]
- daf.typing.unions.is_known1d(data: Any) TypeGuard[Known1D] [source]¶
Assert that some
data
isKnown1D
(and actually 1D data).
- daf.typing.unions.be_known1d(data: Any) Union[ndarray, Series] [source]¶
Assert that some
data
isKnown1D
, and return it as such formypy
.
- daf.typing.unions.Known2D(*args, **kwargs)¶
Any 2D data type that
daf
knows about.Due to
numpy.ndarray
type annotation limitations, we can’t usemypy
to ensure this is actually 2D data.alias of
Union
[ndarray
,_fake_sparse.spmatrix
,DataFrame
]
- daf.typing.unions.is_known2d(data: Any) TypeGuard[Known2D] [source]¶
Assert that some
data
isKnown2D
(and actually 2D data).
- daf.typing.unions.be_known2d(data: Any) Union[_vectors.Vector, Series, _dense.DenseInRows, SparseInRows, FrameInRows, _dense.DenseInColumns, SparseInColumns, FrameInColumns] [source]¶
Assert that some
data
isKnown2D
(and actually 2D data), and return it as such formypy
.
- daf.typing.unions.Proper(*args, **kwargs)¶
Any “proper” 1D/2D data type that
daf
fully supports.Such data need not be
is_optimal
.alias of
Union
[_vectors.Vector
,Series
,_dense.DenseInRows
,SparseInRows
,FrameInRows
,_dense.DenseInColumns
,SparseInColumns
,FrameInColumns
]
- daf.typing.unions.is_proper(data: Any, *, dtype: Optional[_dtypes.DTypes] = None) TypeGuard[Proper] [source]¶
Assert that some
data
isProper
, optionally only of somedtype
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.be_proper(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None) Union[_vectors.Vector, Series, _dense.DenseInRows, SparseInRows, FrameInRows, _dense.DenseInColumns, SparseInColumns, FrameInColumns] [source]¶
Assert that some
data
isProper
, optionally only of somedtype
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.Proper1D(*args, **kwargs)¶
Any “proper” 1D data type that
daf
fully supports.alias of
Union
[_vectors.Vector
,Series
]
- daf.typing.unions.is_proper1d(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, size: Optional[int] = None) TypeGuard[Proper1D] [source]¶
Assert that some
data
isProper1D
,, optionally only of somedtype
, optionally only of somesize
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.be_proper1d(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, size: Optional[int] = None) Union[_vectors.Vector, Series] [source]¶
Assert that some
data
isProper1D
, optionally only of somedtype
, optionally only of somesize
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.Proper2D(*args, **kwargs)¶
Any “proper” 2D data type that
daf
fully supports.alias of
Union
[_dense.DenseInRows
,SparseInRows
,FrameInRows
,_dense.DenseInColumns
,SparseInColumns
,FrameInColumns
]
- daf.typing.unions.is_proper2d(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None, layout: Optional[_layouts.AnyMajor] = None) TypeGuard[Proper2D] [source]¶
Assert that some
data
isProper2D
, optionally only of somedtype
, optionally only of someshape
, optionally optionally only of a specificlayout
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.be_proper2d(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[_dense.DenseInRows, SparseInRows, FrameInRows, _dense.DenseInColumns, SparseInColumns, FrameInColumns] [source]¶
Assert that some
data
isProper2D
, optionally only of somedtype
, optionally only of someshape
, optionally optionally only of a specificlayout
, and return it as such formypy
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.ProperInRows(*args, **kwargs)¶
Any “proper”
ROW_MAJOR
2D data type thatdaf
fully supports.alias of
Union
[_dense.DenseInRows
,SparseInRows
,FrameInRows
]
- daf.typing.unions.is_proper_in_rows(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[ProperInRows] [source]¶
Assert that some
data
isProperInRows
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.be_proper_in_rows(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) Union[_dense.DenseInRows, SparseInRows, FrameInRows] [source]¶
Assert that some
data
isProperInRows
, 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.unions.ProperInColumns(*args, **kwargs)¶
Any “proper”
COLUMN_MAJOR
2D data type thatdaf
fully supports.alias of
Union
[_dense.DenseInColumns
,SparseInColumns
,FrameInColumns
]
- daf.typing.unions.is_proper_in_columns(data: Any, *, dtype: Optional[_dtypes.DTypes] = None, shape: Optional[Tuple[int, int]] = None) TypeGuard[ProperInColumns] [source]¶
Assert that some
data
isProperInColumns
, optionally only of somedtype
, optionally only of someshape
.By default, checks that the data type is one of
ALL_DTYPES
.
- daf.typing.unions.be_proper_in_columns(data: Any, *, dtype: Optional[Union[str, dtype, Collection[str], Collection[dtype], Collection[Union[str, dtype]]]] = None, shape: Optional[Tuple[int, int]] = None) Union[_dense.DenseInColumns, SparseInColumns, FrameInColumns] [source]¶
Assert that some
data
isProperInColumns
, 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
.