ndarray

Extension of nptyping NDArray for pydantic that allows for JSON-Schema serialization

Note

This module should only have the NDArray class in it, because the type stub ndarray.pyi is only created for NDArray . Otherwise, type checkers will complain about using any helper functions elsewhere - those all belong in numpydantic.schema .

Keeping with nptyping’s style, NDArrayMeta is in this module even if it’s excluded from the type stub.

class NDArrayMeta(name: str, *args: Any, **kwargs: Any)[source]

Hooking into nptyping’s array metaclass to override methods pending completion of the transition away from nptyping

class NDArray(*_: Any, **__: Any)[source]

Constrained array type allowing npytyping syntax for dtype and shape validation and serialization.

Integrates with pydantic such that - JSON schema for list of list encoding - Serialized as LoL, with automatic compression for large arrays - Automatic coercion from lists on instantiation

Also supports validation on NDArrayProxy types for lazy loading.

References