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 instantiated or used for type checking, it implements the ``__get_pydantic_core_schema__` method to invoke the relevant interface for validation and serialization.

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