qat.utils.pydantic module
- class AllowExtraFieldsModel(**data)
Bases:
BaseModel- A Pydantic BaseModel with the extra constraints:
Assignment of fields after initialisation is checked again.
Extra fields given to the model are ignored (default behaviour in BaseModel).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class FrozenDict(root=PydanticUndefined, **data)
Bases:
PydDictBaseA Pydantic dict that is immutable after instantiation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- root: pyd_frozendict[K, V]
- class FrozenSet(root=PydanticUndefined, **data)
Bases:
PydSetBaseA Pydantic set that is immutable after instantiation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- root: frozenset[V]
- class NoExtraFieldsFrozenModel(**data)
Bases:
NoExtraFieldsModel- A Pydantic BaseModel with the extra constraints:
Assignment of fields after initialisation is checked again.
Extra fields given to the model are not ignored (default behaviour in BaseModel),
but raise an error now.
# All fields are frozen upon instantiation.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True, 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class NoExtraFieldsModel(**data)
Bases:
BaseModel- A Pydantic BaseModel with the extra constraints:
Assignment of fields after initialisation is checked again.
Extra fields given to the model are not ignored (default behaviour in BaseModel),
but raise an error now.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class PydArray(*args, value: NDArray[Any, int | float | complex | bool])
Bases:
NoExtraFieldsModel,NDArrayOperatorsMixin- A data class wrapper to handle the information needed to completely describe a numpy array:
Value is the numpy array itself
Shape is the shape of the numpy array
dtype is the data (implied) type of the numpy array
Through annotations, this allows creation of metadata classes on top of PydArray that describe how to (de)serialise a (blob) PydArray object according to some (required) type. See _validator() and _serializer().
Enlisting the array data as (nested) list(s) is not optimal, and this class renders (de)serialisation fast.
This class also mixes in NDArrayOperatorsMixin, which defines Python arithmetic operators in terms of NumPy ufuncs. This does NOT guarantee full interoperability with NumPy but allows the option to extend this support in the future. For now, the sole purpose of this class is ONLY to be a data class wrapper and mediator for (de)serialisation purposes.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'ser_json_inf_nan': 'constants', 'use_enum_values': False, 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context, /)
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Return type:
None
- Args:
self: The BaseModel instance. context: The context.
- class PydDictBase(root=PydanticUndefined, **data)
Bases:
RootModel[dict[~GeneralKey, ~GeneralValue]]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- get(key, default=None)
- items()
- keys()
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pop(key, *args, **kwargs)
- root: dict[K, V]
- values()
- class PydListBase(root=PydanticUndefined, **data)
Bases:
RootModel[list[~GeneralValue]]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- root: list[V]
- class PydSetBase(root=PydanticUndefined, **data)
Bases:
RootModel[set[~GeneralValue]]Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- root: set[V]
- class PydValidatedBase(root=PydanticUndefined, **data)
Bases:
RootModelBase class for validated Pydantic containers.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- validate_value(value)
- validation_setup()
Setup validation for the container.
- class RehydratableModel(**data)
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- property object_type: str
Returns the type of the object, which is the class name.
- class ValidatedDict(root=PydanticUndefined, **data)
Bases:
PydDictBase,PydValidatedBaseA dict object that validates the input added after instantiation. This way, we are sure that the elements in a dict are only of a certain type. Pydantic containers only validate upon instantiation, not when modifying the container.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- update(data)
- validate_key(key)
- validation_setup()
Validate the types of keys and values in the dictionary.
- class ValidatedList(root=PydanticUndefined, **data)
Bases:
PydListBase,PydValidatedBaseA list object that validates the input appended/extended after instantiation. This way, we are sure that the elements in a list are only of a certain type. Pydantic containers only validate upon instantiation, not when modifying the container.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- append(value)
- extend(values)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- remove(value)
- class ValidatedSet(root=PydanticUndefined, **data)
Bases:
PydSetBase,PydValidatedBaseA set object that validates the input added after instantiation. This way, we are sure that the elements in a set are only of a certain type. Pydantic containers only validate upon instantiation, not when modifying the container.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- add(value)
- discard(value)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pop()
- remove(value)
- update(*sets)
- annotate_pyd_array(ty)
Creates an annotated type for numeric lists with Pydantic serializers and validators for efficient serialization.
- find_all_subclasses(cls)
Recursively finds nested subclasses of a class.
- Return type:
list[Type]
- validate_calibratable_positive_float(value)
- validate_calibratable_unit_interval(value)
- validate_calibratable_unit_interval_array(array)
- validate_non_negative(value)
- validate_qubit_coupling(value)
- validate_waveform_type(value)