numpydantic¶
Top-level API contents
- class NDArray(val: NDArrayType)[source]¶
Constrained array type allowing npytyping syntax for dtype and shape validation and serialization.
This class is not intended to be instantiable, and support for static type checking is limited, it implements the
__get_pydantic_core_schema__method to invoke the relevant interface for validation and serialization.It is callable, however, which validates and attempts to coerce input to a supported array type. There is no such thing as an “NDArray instance,” but one can think of it as a validating passthrough callable.
References
- class Shape(*_: Any, **__: Any)[source]¶
A container for shape expressions that describe the shape of an multi dimensional array.
Simple example:
>>> Shape['2, 2'] Shape['2, 2']
A Shape can be compared to a typing.Literal. You can use Literals in NDArray as well.
>>> from typing import Literal
>>> Shape['2, 2'] == Literal['2, 2'] True