Array-likes
Similar to the numpy._typing._ArrayLike{}_co coercible array-like types,
optype.numpy provides the optype.numpy.To{}ND. Unlike the ones in numpy, these
don't accept "bare" scalar types (the __len__ method is required).
Additionally, there are the To{}1D, To{}2D, and To{}3D for vector-likes,
matrix-likes, and cuboid-likes, and the To{} aliases for "bare" scalar types.
builtins |
numpy |
optype.numpy |
|||
|---|---|---|---|---|---|
| exact scalar types | scalar-like | {1,2,3,N}-d array-like |
strict {1,2,3}-d array-like |
||
False |
False_ |
ToJustFalse |
|||
False| 0
|
False_ |
ToFalse |
|||
True |
True_ |
ToJustTrue |
|||
True| 1
|
True_ |
ToTrue |
|||
bool |
bool_ |
ToJustBool |
ToJustBool{}D |
ToJustBoolStrict{}D |
|
bool| 0| 1
|
bool_ |
ToBool |
ToBool{}D |
ToBoolStrict{}D |
|
~int |
integer |
ToJustInt |
ToJustInt{}D |
ToJustIntStrict{}D |
|
int| bool
|
integer| bool_
|
ToInt |
ToInt{}D |
ToIntStrict{}D |
|
float16 |
ToJustFloat16 |
ToJustFloat16_{}D |
ToJustFloat16Strict{}D |
||
float16| int8| uint8| bool_
|
ToFloat32 |
ToFloat32_{}D |
ToFloat32Strict{}D |
||
float32 |
ToJustFloat32 |
ToJustFloat32_{}D |
ToJustFloat32Strict{}D |
||
float32| float16| int16| uint16| int8| uint8| bool_
|
ToFloat32 |
ToFloat32_{}D |
ToFloat32Strict{}D |
||
~float |
float64 |
ToJustFloat64 |
ToJustFloat64_{}D |
ToJustFloat64Strict{}D |
|
float| int| bool
|
float64| float32| float16| integer| bool_
|
ToFloat64 |
ToFloat64_{}D |
ToFloat64Strict{}D |
|
~float |
floating |
ToJustFloat |
ToJustFloat{}D |
ToJustFloatStrict{}D |
|
float| int| bool
|
floating| integer| bool_
|
ToFloat |
ToFloat{}D |
ToFloatStrict{}D |
|
complex64 |
ToJustComplex64 |
ToJustComplex64_{}D |
ToJustComplex64Strict{}D |
||
complex64| float32| float16| int16| uint16| int8| uint8| bool_
|
ToComplex64 |
ToComplex64_{}D |
ToComplex64Strict{}D |
||
~complex |
complex128 |
ToJustComplex128 |
ToJustComplex128_{}D |
ToJustComplex128Strict{}D |
|
complex| float| int| bool
|
complex128| complex64| float64| float32| float16| integer| bool_
|
ToComplex128 |
ToComplex128_{}D |
ToComplex128Strict{}D |
|
~complex |
complexfloating |
ToJustComplex |
ToJustComplex{}D |
ToJustComplexStrict{}D |
|
complex| float| int| bool
|
number| bool_
|
ToComplex |
ToComplex{}D |
ToComplexStrict{}D |
|
complex| float| int| bool
| bytes| str |
generic |
ToScalar |
ToArray{}D |
ToArrayStrict{}D |
|
Note
The To*Strict{1,2,3}D aliases were added in optype 0.7.3.
These array-likes with strict shape-type require the shape-typed input to be
shape-typed.
This means that e.g. ToFloat1D and ToFloat2D are disjoint (non-overlapping),
and makes them suitable to overload array-likes of a particular dtype for different
numbers of dimensions.
Note
The ToJust{Bool,Float,Complex}* type aliases were added in optype 0.8.0.
See optype.Just for more information.
Note
The To[Just]{False,True} type aliases were added in optype 0.9.1.
These only include the np.bool types on numpy>=2.2. Before that, np.bool
wasn't generic, making it impossible to distinguish between np.False_ and np.True_
using static typing.
Note
The ToArrayStrict{1,2,3}D types are generic since optype 0.9.1, analogous to
their non-strict dual type, ToArray{1,2,3}D.
Note
The To[Just]{Float16,Float32,Complex64}* type aliases were added in optype 0.12.0.
Source code: optype/numpy/_to.py