Interfaces¶
Base Interface metaclass
- class Interface(shape: Tuple[int, ...] | Any, dtype: str | type | Any | generic)[source]¶
Abstract parent class for interfaces to different array formats
- before_validation(array: Any) NDArrayType[source]¶
Optional step pre-validation that coerces the input into a type that can be validated for shape and dtype
Default method is a no-op
- validate_dtype(array: NDArrayType) NDArrayType[source]¶
Validate the dtype of the given array, returning it unmutated.
- Raises:
DtypeError –
- validate_shape(array: NDArrayType) NDArrayType[source]¶
Validate the shape of the given array, returning it unmutated
- Raises:
ShapeError –
- after_validation(array: NDArrayType) T[source]¶
Optional step post-validation that coerces the intermediate array type into the return type
Default method is a no-op
- abstract classmethod check(array: Any) bool[source]¶
Method to check whether a given input applies to this interface
- abstract classmethod enabled() bool[source]¶
Check whether this array interface can be used (eg. its dependent packages are installed, etc.)
- classmethod to_json(array: Type[T], info: SerializationInfo | None = None) list | dict[source]¶
Convert an array of
return_typeto a JSON-compatible format using base python types
- classmethod return_types() Tuple[NDArrayType, ...][source]¶
Return types for all enabled interfaces