List of supported types#

Base types#

NoneType

A Pydantic compatible 'type' which only accepts None.

Complex

Range

Slice

Number

This type does not support coercion, only validation.

Integral

This type does not support coercion, only validation.

Real

This type generally does not support coercion, only validation.

Type

Make types serializable; the serialization format is

Functions#

PureFunction

A Pydantic-compatible function type, which supports deserialization.

A function is termed “pure” if its output depends only on its inputs. If you serialize a function as part of a reproducible workflow, this is generally what you want.

NumPy types#

DType

Validator also accepts str and scalar types (int, np.float32, etc.).

NPValue

Use this to use a NumPy dtype for type annotation; pydantic will recognize the type and execute appropriate validation/parsing.

Array

Use this to specify a NumPy array type annotation; pydantic will recognize the type and execute appropriate validation/parsing.

NPGenerator

alias of RNGenerator

RandomState

Pydantic typing support for the legacy RandomState object.

SciPy distributions#

Distribution

Pydantic-aware type for SciPy _frozen_ distributions.

UniDistribution

MvDistribution

MvNormalDistribution

Univariate distributions in scipy.stats are implemented in a generic manner, which allows us to support all of them with the same type annotation UniDistribution. This is different for multivariate, which each require their own type.

MvDistribution is an abstract type for all multivariate distributions, and Distribution an abstract type for all univariate and multivariate ones.

Units#

Pint#

PintQuantity

A value with pint units, e.g. 1*ureg.s.

PintUnit

Quantities#

QuantitiesQuantity

QuantitiesUnit

Exactly the same as QuantitiesValue, except that we enforce the magnitude to be 1.

QuantitiesDimension

PyTorch#

Tensor

alias of TorchTensor

Module

alias of TorchModule

torch_module_state_decoder

Decode a torch module state serialized with torch_module_state_reduce.

torch_module_state_encoder

Encode to PyTorch model state into an ASCII string, which can be included in a JSON file.

Generator

alias of TorchGenerator