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
dafknows about.Due to
numpy.ndarraytype annotation limitations, we can’t usemypyto 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
dataisKnown(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
dataisKnown(and actually 1D/2D data), and return it as such formypy.
- daf.typing.unions.Known1D(*args, **kwargs)¶
Any 1D data type that
dafknows about.Due to
numpy.ndarraytype annotation limitations, we can’t usemypyto ensure this is actually 1D data.alias of
Union[ndarray,Series]
- daf.typing.unions.is_known1d(data: Any) TypeGuard[Known1D][source]¶
Assert that some
dataisKnown1D(and actually 1D data).
- daf.typing.unions.be_known1d(data: Any) Union[ndarray, Series][source]¶
Assert that some
dataisKnown1D, and return it as such formypy.
- daf.typing.unions.Known2D(*args, **kwargs)¶
Any 2D data type that
dafknows about.Due to
numpy.ndarraytype annotation limitations, we can’t usemypyto 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
dataisKnown2D(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
dataisKnown2D(and actually 2D data), and return it as such formypy.
- daf.typing.unions.Proper(*args, **kwargs)¶
Any “proper” 1D/2D data type that
daffully 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
dataisProper, 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
dataisProper, 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
daffully 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
dataisProper1D,, 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
dataisProper1D, 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
daffully 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
dataisProper2D, 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
dataisProper2D, 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_MAJOR2D data type thatdaffully 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
dataisProperInRows.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
dataisProperInRows, 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_MAJOR2D data type thatdaffully 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
dataisProperInColumns, 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
dataisProperInColumns, 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.