numpydantic#

Top-level API contents

apply_patches() None#

Apply all monkeypatches!

class NDArray(*_: Any, **__: Any)#

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

class Any(*args, **kwargs)#

Special type indicating an unconstrained type.

  • Any is compatible with every type.

  • Any assumed to have all methods.

  • All values assumed to be instances of Any.

Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance checks.

Float#

alias of float64

Int#

alias of integer

Number#

alias of number

class Shape(*_: Any, **__: Any)#

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
UInt8#

alias of uint8