7. Reference documentation
MuPIF classes are organized in a hierarchy, which is briefly described here:
graph TD;
mupif.ObjectBase-->BareData
WithMetadata-->Data
BareData-->Data
mupif.ObjectBase-->Process
mupif.ObjectBase-->Utility
WithMetadata-->Process
ObjectBaseDefines attribute handling and validation (e.g. keywords passed to constructor are assigned to attributes)
WithMetadataAdds metadata to each instance
BareDataAdds RPC capabilities (Pyro) and serialization (Pyro, JSON, …)
DataData with metadata
ProcessObjects standing for processes, such as Model and Workflow
UtilityOther objects which don’t fit anywhere else; typically proxy classes such as
mupif.PyroFileormupif.RefQuantity
- exception mupif.APIError
Bases:
ExceptionThis class serves as a base class for exceptions thrown by the framework. Raising an exception is a way to signal that a routine could not execute normally - for example, when an input argument is invalid (e.g. value is outside of the domain of a function) or when a resource it relies on is unavailable (like a missing file, a hard disk error, or out-of-memory errors)
Exceptions provide a way to react to exceptional circumstances (like runtime errors) in programs by transferring control to special functions called handlers. To catch exceptions, a portion of code is placed under exception inspection. This is done by enclosing that portion of code in a try-block. When an exceptional circumstance arises within that block, an exception is thrown that transfers the control to the exception handler. If no exception is thrown, the code continues normally and all handlers are ignored.
An exception is thrown by using the throw keyword from inside the “try” block. Exception handlers are declared with the keyword “except”, which must be placed immediately after the try block.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mupif.BBox(coords_ll, coords_ur)
Bases:
BaseModelRepresents a bounding box - a rectange in 2D and prism in 3D. Its geometry is described using two points - lover left and upper right corners. The bounding box class provides fast and efficient methods for testing whether point is inside it and whether intersection with other BBox exist.
- __init__(coords_ll, coords_ur)
Constructor.
- Parameters:
coords_ll (tuple or list) – Tuple or list with coordinates of lower left corner
coords_ur (tuple or list) – Tuple or list with coordinates of uper right corner
- __str__()
- Returns:
Returns lower left and upper right coordinate of the bounding box
- Return type:
str
- containsPoint(point)
Check whether a point lies within a receiver.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if point is inside receiver, otherwise False
- Return type:
bool
- coords_ll: Tuple[float, float] | Tuple[float, float, float]
- coords_ur: Tuple[float, float] | Tuple[float, float, float]
- intersects(bbox: BBox)
Check intersection of a receiver with a bounding box
- Parameters:
bbox (BBox) – an instance of BBox class
- Returns:
Returns True if receiver intersects given bounding box, otherwise False
- Return type:
bool
- merge(entity)
Merges receiver with given entity (position vector or a BBox).
- Parameters:
entity (BBox) – 1D/2D/3D position vector or
entity – an instance of BBox class
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'coords_ll': FieldInfo(annotation=Union[Tuple[float, float], Tuple[float, float, float]], required=True), 'coords_ur': FieldInfo(annotation=Union[Tuple[float, float], Tuple[float, float, float]], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.BareData
Bases:
ObjectBaseBase class for all serializable (baredata) objects; all objects which are sent over the wire via python must be recursively baredata, basic structures thereof (tuple, list, dict) or primitive types. There are some types handled in a special way, such as enum.IntEnum. Instance is reconstructed by classing the
__new__method of the class (bypassing constructor) and processingdumpAttrs:- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
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.
- Args:
self: The BaseModel instance. context: The context.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.Brick_3d_lin(*, number: int, label: int | None = None, vertices: Tuple[int, ...], mesh: Mesh | None = None)
Bases:
CellUnstructured 3d tetrahedral element with linear interpolation
- _evalN(lc: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Evaluates shape functions at given point (given in parametric coordinates) :param tuple lc: A local coordinate :return: shape function :rtype: tuple of float
- containsPoint(point) bool
Check if a cell contains a point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if cell contains a given point
- Return type:
bool
- getBBox(relPad=1e-05)
Return bounding box. The box is by default slightly enlarged via relPad to avoid finite-precision issues when testing for a boundary point being inside the box.
- Parameters:
relPad (float) – relative padding of the box; tight (geometrical) bbox will be enlarged along each axis by relPad times size along that axis, in both directions.
- Returns:
Returns a bounding box of the receiver
- Return type:
- static getClassForCellGeometryType(cgt)
Return class object (not instance) for given cell geometry type. Does introspection of all subclasses of Cell caches the result.
- classmethod getGeometryType() CGT
Returns geometry type of receiver.
- Returns:
Returns geometry type of receiver
- Return type:
CellGeometryType
- getMeshioGeometryStr() str
- getNumberOfVertices()
- Returns:
Number of vertices
- Return type:
int
- getTransformationJacobian(coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float
Returns the transformation jacobian (the determinant of jacobian) of the receiver
- Parameters:
coords (tuple) – local (parametric) coordinates of the point
- Returns:
jacobian
- Return type:
float
- getVertices()
- Returns:
The list of cell vertices
- Return type:
tuple
- glob2loc(coords) float64'>)]]
Converts global coordinate to local (area) coordinate.
- Parameters:
coords (tuple) – A coordinate in global system
- Returns:
local (area) coordinate
- Return type:
tuple
- interpolate(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)], vertexValues: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[8, 1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Interpolates given vertex values to a given point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
vertexValues (tuple) – A tuple containing vertex values
- Returns:
Interpolated value at a given point
- Return type:
tuple
- label: Optional[int]
Cell label, arbitrary unique number.
- loc2glob(lc: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Converts local (parametric) coordinates to global ones
- Parameters:
lc (tuple) – A local coordinate
- Returns:
global coordinate
- Return type:
tuple
- mesh: Optional['Mesh']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'mesh': FieldInfo(annotation=Union[Mesh, NoneType], required=False, default=None, exclude=True), 'number': FieldInfo(annotation=int, required=True), 'vertices': FieldInfo(annotation=Tuple[int, ...], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local cell number; local numbering should start from 0 and should be continuous.
- vertices: Tuple[int, ...]
Cell vertices (local numbers)
- class mupif.Cell
Bases:
BareDataRepresentation of a computational cell.
The solution domain is composed of cells (e.g. finite element), whose geometry is defined using vertices (e.g. nodes). Cells provide interpolation over their associated volume, based on given vertex values. Derived classes will be implemented to support common interpolation cells (finite elements, FD stencils, etc.)
- __init__(**data: Any) None
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.
- containsPoint(point) bool
Check if a cell contains a point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if cell contains a given point
- Return type:
bool
- getBBox(relPad=1e-05)
Return bounding box. The box is by default slightly enlarged via relPad to avoid finite-precision issues when testing for a boundary point being inside the box.
- Parameters:
relPad (float) – relative padding of the box; tight (geometrical) bbox will be enlarged along each axis by relPad times size along that axis, in both directions.
- Returns:
Returns a bounding box of the receiver
- Return type:
- static getClassForCellGeometryType(cgt)
Return class object (not instance) for given cell geometry type. Does introspection of all subclasses of Cell caches the result.
- classmethod getGeometryType() CGT
Returns geometry type of receiver.
- Returns:
Returns geometry type of receiver
- Return type:
CellGeometryType
- getMeshioGeometryStr() str
- getNumberOfVertices()
- Returns:
Number of vertices
- Return type:
int
- getTransformationJacobian(coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float
Returns the transformation jacobian (the determinant of jacobian) of the receiver
- Parameters:
coords (tuple) – local (parametric) coordinates of the point
- Returns:
jacobian
- Return type:
float
- getVertices()
- Returns:
The list of cell vertices
- Return type:
tuple
- interpolate(point, vertexValues) float64'>)]
Interpolates given vertex values to a given point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
vertexValues (tuple) – A tuple containing vertex values
- Returns:
Interpolated value at a given point
- Return type:
tuple
- label: Optional[int]
Cell label, arbitrary unique number.
- mesh: Optional['Mesh']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'mesh': FieldInfo(annotation=Union[Mesh, NoneType], required=False, default=None, exclude=True), 'number': FieldInfo(annotation=int, required=True), 'vertices': FieldInfo(annotation=Tuple[int, ...], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local cell number; local numbering should start from 0 and should be continuous.
- vertices: Tuple[int, ...]
Cell vertices (local numbers)
- class mupif.ConstantField(*, metadata: ~mupif.field.FieldMeta = FieldMeta(Units=None, Type='mupif.field.Field', Type_ID=None, FieldType=None, ValueType=None), quantity: ~astropy.units.quantity.Quantity | ~mupif.units.RefQuantity, valueType: ~mupif.mupifquantity.ValueType = ValueType.Scalar, fieldID: ~mupif.dataid.DataID, time: ~astropy.units.quantity.Quantity = <Quantity 0. s>, mesh: ~mupif.mesh.Mesh, fieldType: ~mupif.field.FieldType = FieldType.FT_vertexBased)
Bases:
FieldRepresentation of field with constant value. Field is a scalar, vector, or tensorial quantity defined on a spatial domain.
- _evaluate(position, eps)
Evaluates the receiver at a single spatial position.
- Parameters:
position (tuple) – 1D/2D/3D position vector
eps (float) – Optional tolerance
- Returns:
field value
- Return type:
tuple of doubles
Note
This method has some issues related to https://sourceforge.net/p/mupif/tickets/22/ .
- copyToHeavy(h5grp)
- dataDigest()
- evaluate(positions, eps=0.0)
Evaluates the receiver at given spatial position(s).
- Parameters:
positions (tuple, a list of tuples) – 1D/2D/3D position vectors
eps (float) – Optional tolerance for probing whether the point belongs to a cell (should really not be used)
- Returns:
field value(s)
- Return type:
Physics.PhysicalQuantity with given value or tuple of values
- field2Image2DBlock()
Block an open window from matPlotLib. Waits until closed.
- getCellValue(cellID)
Returns the value associated with a given cell.
- Parameters:
cellID (int) – Cell identifier
- Returns:
The value
- Return type:
Physics.PhysicalQuantity
- getDataID()
Returns DataID, e.g. FID_Displacement, FID_Temperature.
- Returns:
Returns field DataID
- Return type:
- getFieldID()
Returns DataID, e.g. FID_Displacement, FID_Temperature.
- Returns:
Returns field ID
- Return type:
- getFieldIDName()
Returns name of the field.
- Returns:
Returns fieldID name
- Return type:
string
- getFieldType()
Returns receiver field type (values specified as vertex or cell values)
- Returns:
Returns fieldType id
- Return type:
- getMartixForTensor(values)
Reshape values to a list with 3x3 arrays. Usable for VTK export.
- Parameters:
values (list) – List containing tuples of 9 values, e.g. [(1,2,3,4,5,6,7,8,9), (1,2,3,4,5,6,7,8,9), …]
- Returns:
List containing 3x3 matrices for each tensor
- Return type:
list
- getQuantity()
- getRecord(componentID)
Return value in one point (cell, vertex or similar)
- getRecordQuantity(componentID)
Return value in one point (cell, vertex or similar)
- getRecordSize()
Return the number of scalars per value, depending on
valueTypepassed when constructing the instance.- Returns:
number of scalars (1,3,9 respectively for scalar, vector, tensor)
- Return type:
int
- getTime()
Get time of the field.
- Returns:
Time of field data
- Return type:
units.Quantity
- getValue()
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- getVertexValue(vertexID)
Returns the value associated with a given vertex.
- Parameters:
vertexID (int) – Vertex identifier
- Returns:
The value
- Return type:
Physics.PhysicalQuantity
- giveValue(componentID)
Returns the value associated with a given component (vertex or cell).
- Parameters:
componentID (int) – An identifier of a component: vertexID or cellID
- Returns:
The value
- Return type:
tuple
- inUnitsOf(*units)
Should return a new instance. As deep copy is expensive, this operation should be avoided. Better to use convertToUnits method performing in place conversion.
- static makeFromHdf5(*, fileName: str = None, group: str = 'component1/part1', h5group=None, indices: List[int] | None = None, heavy=False, h5own=False)
Restore Fields from HDF5 file.
- Parameters:
fileName (str) – HDF5 file
group (str) – HDF5 group the data will be read from (IOError is raised if the group does not exist).
h5group –
indices –
- Returns:
list of new
Fieldinstances- Return type:
Note
This method has not been tested yet.
- static makeFromHdf5_groups(*, fieldGrp, meshGrp=None, meshCache=None, heavy=False, h5own=False)
- classmethod makeFromHeavy(*, h5grp, indices)
- static makeFromMeshioMesh(input: str | ~meshio._mesh.Mesh, unit: dict[str, astropy.units.core.Unit], time: ~astropy.units.quantity.Quantity = <Quantity 0. s>) List[Field]
- static makeFromVtkFile(filename: str, units: dict[str, astropy.units.core.Unit] = {}, fieldIDs: dict[str, mupif.dataid.DataID] = {}, time: ~astropy.units.quantity.Quantity = <Quantity 0. s>)
- merge(field)
Merges the receiver with given field together. Both fields should be on different parts of the domain (can also overlap), but should refer to same underlying discretization, otherwise unpredictable results can occur.
- Parameters:
field (Field) – given field to merge with.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'fieldID': FieldInfo(annotation=DataID, required=True), 'fieldType': FieldInfo(annotation=FieldType, required=False, default=<FieldType.FT_vertexBased: 1>), 'mesh': FieldInfo(annotation=Mesh, required=True), 'metadata': FieldInfo(annotation=FieldMeta, required=False, default=FieldMeta(Units=None, Type='mupif.field.Field', Type_ID=None, FieldType=None, ValueType=None)), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'time': FieldInfo(annotation=Quantity, required=False, default=<Quantity 0. s>), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- plot2D(plane='xy', title=None, fieldComponent=0, warpField=None, warpScale=0.0, fileName=None, show=False, colorbar='horizontal')
Plots and/or saves 2D image using a matplotlib library. Works for structured and unstructured 2D/3D fields. 2D/3D fields need to define plane. This method gives only basic viewing options, for aesthetic and more elaborated output use e.g. VTK field export with postprocessors such as ParaView or Mayavi. Idea from https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#id1
- Parameters:
plane (str) – what plane to extract from field, valid values are ‘xy’, ‘xz’, ‘yz’
fieldComponent (int) – component of the field
colorbar (str) – color bar details. Valid values ‘’ for no colorbar, ‘vertical’ or ‘horizontal’
title (str) – title
fileName (str) – if nonempty, a filename is written to the disk, usually png, pdf, ps, eps and svg are supported
show (bool) – if the plot should be showed
warpField (Field) – vector field to wrap geometry
warpScale (float) – warping scale
- Returns:
handle to matplotlib figure
- property q
- quantity: Union[units.Quantity, units.RefQuantity]
- setRecord(componentID, value)
Sets the value associated with a given component (vertex or cell).
- Parameters:
componentID (int) – An identifier of a component: vertexID or cellID
value (tuple) – Value to be set for a given component, should have the same units as receiver
- setValue(componentID, value)
Sets the value associated with a given component (vertex or cell).
- Parameters:
componentID (int) – An identifier of a component: vertexID or cellID
value (tuple) – New value of the receiver (tuple)
- toHdf5(*, fileName: str = None, groupName='component1/part1', h5group=None, heavyMesh=False)
Dump field to HDF5, in a simple format suitable for interoperability (TODO: document).
- Parameters:
fileName (str) – HDF5 file
groupName (str) –
h5group (str) – HDF5 group the data will be saved under.
The HDF hierarchy is like this:
group | +--- meshes | +----25aa0aa04457 | | +--- [vertex_coords] | | +--- [cell_types] | | \--- [cell_vertices] | +--- 17809e2b86ea | +--- [vertex_coords] | +--- [cell_types] | \--- [cell_vertices] +--- fields +--- 1 | +--- -> meshes/25aa0aa04457 | \--- [vertex_values] +--- 2 | +--- -> meshes/17809e2b86ea | \--- [vertex_values] +--- 3 +--- -> meshes/17809e2b86ea \--- [cell_values]
where
plainnames are HDF (sub)groups,[bracketed]names are datasets,{name=value}are HDF attributes,->prefix indicated HDF5 hardlink (transparent to the user); numerical suffixes (_01, …) are auto-allocated. Mesh objects are hardlinked using HDF5 hardlinks if an identical mesh is already stored in the group, based on hexdigest of its full data.Note
This method has not been tested yet. The format is subject to future changes.
- toHdf5Group(fieldGrp, meshLink=None)
- toHdf5_split_files(fieldPrefix: str, meshPrefix: str, flat=True, heavy=False)
- toMeshioMesh()
- property unit
- property value
- class mupif.ConstantProperty(*, metadata={}, quantity: Quantity | RefQuantity, valueType: ValueType = ValueType.Scalar, propID: DataID, time: Quantity | None = None)
Bases:
Property,DbDictableProperty is a characteristic value of a problem, that does not depend on spatial variable, e.g. homogenized conductivity over the whole domain. Typically, properties are obtained by postprocessing results from lover scales by means of homogenization and are parameters of models at higher scales.
Property value can be of scalar, vector, or tensorial type. Property keeps its value, time and type.
- __init__(*, metadata={}, **kw)
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.
- dataDigest(*args)
- static from_db_dict(d)
- getDataID()
Returns DataID of property. :rtype: DataID
- getQuantity(time=None)
- getTime()
- Returns:
Receiver time
- Return type:
units.Quantity or None
- getValue(time=None)
Returns the value of property in a tuple. :param units.Quantity time: Time of property evaluation
- Returns:
Property value as an array
- Return type:
float or tuple
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- inUnitsOf(unit)
Express the quantity in different units.
- static loadHdf5(hdf5)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=Union[IOMeta, NoneType], required=False, default=None), 'propID': FieldInfo(annotation=DataID, required=True), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'time': FieldInfo(annotation=Union[Quantity, NoneType], required=False, default=None), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- propID: dataid.DataID
- property q
- quantity: Union[units.Quantity, units.RefQuantity]
- saveHdf5(hdf5)
- to_db_dict(dialect: Literal['edm'] | None = None) dict[str, Any]
- to_db_dict_impl()
- property unit
- property value
- class mupif.Data(*, metadata: BaseMeta = BaseMeta())
Bases:
WithMetadata,BareDataBase class for objects which have metadata and are baredata (serializable).
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta())}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.DataID(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
AutoNameThis class represents the supported values of IDs of property, field, etc. Values of members should be stored by .name, .value should not be used.
- FID_BucklingShape = 'FID_BucklingShape'
- FID_Concentration = 'FID_Concentration'
- FID_DepositionRate = 'FID_DepositionRate'
- FID_Displacement = 'FID_Displacement'
- FID_DomainNumber = 'FID_DomainNumber'
- FID_ESI_VPS_Displacement = 'FID_ESI_VPS_Displacement'
- FID_FibreOrientation = 'FID_FibreOrientation'
- FID_FilmConcentration = 'FID_FilmConcentration'
- FID_FilmEvaporationRate = 'FID_FilmEvaporationRate'
- FID_FilmTemperature = 'FID_FilmTemperature'
- FID_FilmThickness = 'FID_FilmThickness'
- FID_Humidity = 'FID_Humidity'
- FID_Material_number = 'FID_Material_number'
- FID_MaxPrincipal_Strain = 'FID_MaxPrincipal_Strain'
- FID_MaxPrincipal_Stress = 'FID_MaxPrincipal_Stress'
- FID_MidPrincipal_Strain = 'FID_MidPrincipal_Strain'
- FID_MidPrincipal_Stress = 'FID_MidPrincipal_Stress'
- FID_MinPrincipal_Strain = 'FID_MinPrincipal_Strain'
- FID_MinPrincipal_Stress = 'FID_MinPrincipal_Stress'
- FID_Mises_Stress = 'FID_Mises_Stress'
- FID_Permeability = 'FID_Permeability'
- FID_Porosity = 'FID_Porosity'
- FID_Pressure = 'FID_Pressure'
- FID_Strain = 'FID_Strain'
- FID_Stress = 'FID_Stress'
- FID_Temperature = 'FID_Temperature'
- FID_Thermal_absorption_surface = 'FID_Thermal_absorption_surface'
- FID_Thermal_absorption_volume = 'FID_Thermal_absorption_volume'
- FID_Velocity = 'FID_Velocity'
- FuncID_ProbabilityDistribution = 'FuncID_ProbabilityDistribution'
- ID_BucklingLoad = 'ID_BucklingLoad'
- ID_CompositeLongitudinalPoissonRatio = 'ID_CompositeLongitudinalPoissonRatio'
- ID_CompositeLongitudinalShearModulus = 'ID_CompositeLongitudinalShearModulus'
- ID_CompositeLongitudinalYoungModulus = 'ID_CompositeLongitudinalYoungModulus'
- ID_CompositeTransversePoissonRatio = 'ID_CompositeTransversePoissonRatio'
- ID_CompositeTransverseShearModulus = 'ID_CompositeTransverseShearModulus'
- ID_CompositeTransverseYoungModulus = 'ID_CompositeTransverseYoungModulus'
- ID_Concentration = 'ID_Concentration'
- ID_Curvature = 'ID_Curvature'
- ID_Displacement = 'ID_Displacement'
- ID_EnergeticDisorder = 'ID_EnergeticDisorder'
- ID_EnergyGap = 'ID_EnergyGap'
- ID_ForceField = 'ID_ForceField'
- ID_GrainState = 'ID_GrainState'
- ID_Humidity = 'ID_Humidity'
- ID_Image = 'ID_Image'
- ID_InputFile = 'ID_InputFile'
- ID_Material_number = 'ID_Material_number'
- ID_MoistureContent = 'ID_MoistureContent'
- ID_MoleculeState = 'ID_MoleculeState'
- ID_None = 'ID_None'
- ID_Permeability = 'ID_Permeability'
- ID_Porosity = 'ID_Porosity'
- ID_Pressure = 'ID_Pressure'
- ID_Strain = 'ID_Strain'
- ID_Stress = 'ID_Stress'
- ID_Temperature = 'ID_Temperature'
- ID_Thermal_absorption_surface = 'ID_Thermal_absorption_surface'
- ID_Thermal_absorption_volume = 'ID_Thermal_absorption_volume'
- ID_VTKFile = 'ID_VTKFile'
- ID_Velocity = 'ID_Velocity'
- PID_Acceleration = 'PID_Acceleration'
- PID_AcentricFactor = 'PID_AcentricFactor'
- PID_Amphiphilicity = 'PID_Amphiphilicity'
- PID_Angular_acceleration = 'PID_Angular_acceleration'
- PID_Angular_velocity = 'PID_Angular_velocity'
- PID_AsorptionSpectrum = 'PID_AsorptionSpectrum'
- PID_BeltTemperature = 'PID_BeltTemperature'
- PID_BeltVelocity = 'PID_BeltVelocity'
- PID_Bond_label = 'PID_Bond_label'
- PID_Bond_type = 'PID_Bond_type'
- PID_BoundaryConfiguration = 'PID_BoundaryConfiguration'
- PID_Braking_Force = 'PID_Braking_Force'
- PID_CROSSLINKER_TYPE = 'PID_CROSSLINKER_TYPE'
- PID_CROSSLINKONG_DENSITY = 'PID_CROSSLINKONG_DENSITY'
- PID_Charge = 'PID_Charge'
- PID_Charge_density = 'PID_Charge_density'
- PID_Chemical_specie = 'PID_Chemical_specie'
- PID_ChipSpectrum = 'PID_ChipSpectrum'
- PID_Cohesion_energy_density = 'PID_Cohesion_energy_density'
- PID_Cohesive_group = 'PID_Cohesive_group'
- PID_CollisionDiameter = 'PID_CollisionDiameter'
- PID_Collision_operator = 'PID_Collision_operator'
- PID_CompositeAxialYoung = 'PID_CompositeAxialYoung'
- PID_CompositeDensity = 'PID_CompositeDensity'
- PID_CompositeInPlanePoisson = 'PID_CompositeInPlanePoisson'
- PID_CompositeInPlaneShear = 'PID_CompositeInPlaneShear'
- PID_CompositeInPlaneYoung = 'PID_CompositeInPlaneYoung'
- PID_CompositeStrain11Tensor = 'PID_CompositeStrain11Tensor'
- PID_CompositeStrain22Tensor = 'PID_CompositeStrain22Tensor'
- PID_CompositeStress11Tensor = 'PID_CompositeStress11Tensor'
- PID_CompositeTransversePoisson = 'PID_CompositeTransversePoisson'
- PID_CompositeTransverseShear = 'PID_CompositeTransverseShear'
- PID_Concentration = 'PID_Concentration'
- PID_Contact_angle = 'PID_Contact_angle'
- PID_CorneringAngle = 'PID_CorneringAngle'
- PID_CorneringStiffness = 'PID_CorneringStiffness'
- PID_Coupling_time = 'PID_Coupling_time'
- PID_CriticalDensity = 'PID_CriticalDensity'
- PID_CriticalForce = 'PID_CriticalForce'
- PID_CriticalLoadLevel = 'PID_CriticalLoadLevel'
- PID_CriticalMoment = 'PID_CriticalMoment'
- PID_CriticalPressure = 'PID_CriticalPressure'
- PID_CriticalTemperature = 'PID_CriticalTemperature'
- PID_Crystal_storage = 'PID_Crystal_storage'
- PID_CumulativeConcentration = 'PID_CumulativeConcentration'
- PID_Current = 'PID_Current'
- PID_Cutoff_distance = 'PID_Cutoff_distance'
- PID_DENSITY = 'PID_DENSITY'
- PID_DENSITY_OF_FUNCTIONALIZATION = 'PID_DENSITY_OF_FUNCTIONALIZATION'
- PID_Debye_length = 'PID_Debye_length'
- PID_Deflection = 'PID_Deflection'
- PID_Degree_of_polymerization = 'PID_Degree_of_polymerization'
- PID_Delta_displacement = 'PID_Delta_displacement'
- PID_Demo_Integral = 'PID_Demo_Integral'
- PID_Demo_Max = 'PID_Demo_Max'
- PID_Demo_Min = 'PID_Demo_Min'
- PID_Demo_Value = 'PID_Demo_Value'
- PID_Demo_Volume = 'PID_Demo_Volume'
- PID_Density = 'PID_Density'
- PID_DepositionRate = 'PID_DepositionRate'
- PID_DepositionRateType = 'PID_DepositionRateType'
- PID_Description = 'PID_Description'
- PID_Dielectric_constant = 'PID_Dielectric_constant'
- PID_Diffusion_coefficient = 'PID_Diffusion_coefficient'
- PID_Diffusion_velocity = 'PID_Diffusion_velocity'
- PID_Dimension = 'PID_Dimension'
- PID_Direction = 'PID_Direction'
- PID_DisplacementCurve = 'PID_DisplacementCurve'
- PID_Distribution = 'PID_Distribution'
- PID_DoFMotion = 'PID_DoFMotion'
- PID_DynamicViscosityGaseous = 'PID_DynamicViscosityGaseous'
- PID_DynamicViscosityLiquid = 'PID_DynamicViscosityLiquid'
- PID_Dynamic_pressure = 'PID_Dynamic_pressure'
- PID_Dynamic_viscosity = 'PID_Dynamic_viscosity'
- PID_EModulus = 'PID_EModulus'
- PID_ESI_VPS_BUCKL_LOAD = 'PID_ESI_VPS_BUCKL_LOAD'
- PID_ESI_VPS_CRIMP_STIFFNESS = 'PID_ESI_VPS_CRIMP_STIFFNESS'
- PID_ESI_VPS_FIRST_FAILURE_ELE = 'PID_ESI_VPS_FIRST_FAILURE_ELE'
- PID_ESI_VPS_FIRST_FAILURE_MOM = 'PID_ESI_VPS_FIRST_FAILURE_MOM'
- PID_ESI_VPS_FIRST_FAILURE_PLY = 'PID_ESI_VPS_FIRST_FAILURE_PLY'
- PID_ESI_VPS_FIRST_FAILURE_ROT = 'PID_ESI_VPS_FIRST_FAILURE_ROT'
- PID_ESI_VPS_FIRST_FAILURE_VAL = 'PID_ESI_VPS_FIRST_FAILURE_VAL'
- PID_ESI_VPS_MOMENT = 'PID_ESI_VPS_MOMENT'
- PID_ESI_VPS_MOMENT_CURVE = 'PID_ESI_VPS_MOMENT_CURVE'
- PID_ESI_VPS_PLY1_E0c1 = 'PID_ESI_VPS_PLY1_E0c1'
- PID_ESI_VPS_PLY1_E0t1 = 'PID_ESI_VPS_PLY1_E0t1'
- PID_ESI_VPS_PLY1_E0t2 = 'PID_ESI_VPS_PLY1_E0t2'
- PID_ESI_VPS_PLY1_E0t3 = 'PID_ESI_VPS_PLY1_E0t3'
- PID_ESI_VPS_PLY1_G012 = 'PID_ESI_VPS_PLY1_G012'
- PID_ESI_VPS_PLY1_G013 = 'PID_ESI_VPS_PLY1_G013'
- PID_ESI_VPS_PLY1_G023 = 'PID_ESI_VPS_PLY1_G023'
- PID_ESI_VPS_PLY1_NU12 = 'PID_ESI_VPS_PLY1_NU12'
- PID_ESI_VPS_PLY1_NU13 = 'PID_ESI_VPS_PLY1_NU13'
- PID_ESI_VPS_PLY1_NU23 = 'PID_ESI_VPS_PLY1_NU23'
- PID_ESI_VPS_PLY1_RHO = 'PID_ESI_VPS_PLY1_RHO'
- PID_ESI_VPS_PLY1_S12 = 'PID_ESI_VPS_PLY1_S12'
- PID_ESI_VPS_PLY1_XC = 'PID_ESI_VPS_PLY1_XC'
- PID_ESI_VPS_PLY1_XT = 'PID_ESI_VPS_PLY1_XT'
- PID_ESI_VPS_PLY1_YC = 'PID_ESI_VPS_PLY1_YC'
- PID_ESI_VPS_PLY1_YT = 'PID_ESI_VPS_PLY1_YT'
- PID_ESI_VPS_ROTATION = 'PID_ESI_VPS_ROTATION'
- PID_ESI_VPS_ROTATION_CURVE = 'PID_ESI_VPS_ROTATION_CURVE'
- PID_ESI_VPS_SECFO_1 = 'PID_ESI_VPS_SECFO_1'
- PID_ESI_VPS_SECFO_2 = 'PID_ESI_VPS_SECFO_2'
- PID_ESI_VPS_TEND = 'PID_ESI_VPS_TEND'
- PID_ESI_VPS_THNOD_1 = 'PID_ESI_VPS_THNOD_1'
- PID_ESI_VPS_THNOD_2 = 'PID_ESI_VPS_THNOD_2'
- PID_ESI_VPS_TOTAL_MODEL_MASS = 'PID_ESI_VPS_TOTAL_MODEL_MASS'
- PID_ESI_VPS_hPLY = 'PID_ESI_VPS_hPLY'
- PID_EbullitionTemperature = 'PID_EbullitionTemperature'
- PID_Electric_field = 'PID_Electric_field'
- PID_Electron_mass = 'PID_Electron_mass'
- PID_Electrostatic_field = 'PID_Electrostatic_field'
- PID_EmissionSpectrum = 'PID_EmissionSpectrum'
- PID_Energy = 'PID_Energy'
- PID_Energy_well_depth = 'PID_Energy_well_depth'
- PID_EnvTemperature = 'PID_EnvTemperature'
- PID_Equation_of_state_coefficient = 'PID_Equation_of_state_coefficient'
- PID_Euler_angles = 'PID_Euler_angles'
- PID_EvaporationEnthalpy = 'PID_EvaporationEnthalpy'
- PID_ExcitationSpectrum = 'PID_ExcitationSpectrum'
- PID_ExhaustFlowRateChamber1 = 'PID_ExhaustFlowRateChamber1'
- PID_ExhaustFlowRateChamber2 = 'PID_ExhaustFlowRateChamber2'
- PID_ExhaustFlowRateChamber3 = 'PID_ExhaustFlowRateChamber3'
- PID_ExtensionalInPlaneStiffness = 'PID_ExtensionalInPlaneStiffness'
- PID_ExtensionalOutOfPlaneStiffness = 'PID_ExtensionalOutOfPlaneStiffness'
- PID_External_applied_force = 'PID_External_applied_force'
- PID_External_forcing = 'PID_External_forcing'
- PID_FILLER_CONCENTRATION = 'PID_FILLER_CONCENTRATION'
- PID_FILLER_DESIGNATION = 'PID_FILLER_DESIGNATION'
- PID_FillingTime = 'PID_FillingTime'
- PID_FilmTemperature = 'PID_FilmTemperature'
- PID_FilmThickness = 'PID_FilmThickness'
- PID_Final = 'PID_Final'
- PID_Flow_type = 'PID_Flow_type'
- PID_Flux = 'PID_Flux'
- PID_Footprint = 'PID_Footprint'
- PID_Force = 'PID_Force'
- PID_ForceCurve = 'PID_ForceCurve'
- PID_Friction_coefficient = 'PID_Friction_coefficient'
- PID_Full = 'PID_Full'
- PID_GrainState = 'PID_GrainState'
- PID_HOMO = 'PID_HOMO'
- PID_Hamaker_constant = 'PID_Hamaker_constant'
- PID_HeatCapacityGaseous = 'PID_HeatCapacityGaseous'
- PID_HeatCapacityLiquid = 'PID_HeatCapacityLiquid'
- PID_HeatConductivityGaseous = 'PID_HeatConductivityGaseous'
- PID_HeatConductivityLiquid = 'PID_HeatConductivityLiquid'
- PID_Heat_conductivity = 'PID_Heat_conductivity'
- PID_HeaterTemperature = 'PID_HeaterTemperature'
- PID_Height = 'PID_Height'
- PID_Homogenized_stress_tensor = 'PID_Homogenized_stress_tensor'
- PID_Hyper1 = 'PID_Hyper1'
- PID_Hyper2 = 'PID_Hyper2'
- PID_HyperelasticPotential = 'PID_HyperelasticPotential'
- PID_IdealGasDensity = 'PID_IdealGasDensity'
- PID_InclusionAspectRatio = 'PID_InclusionAspectRatio'
- PID_InclusionDensity = 'PID_InclusionDensity'
- PID_InclusionPoisson = 'PID_InclusionPoisson'
- PID_InclusionSizeNormalized = 'PID_InclusionSizeNormalized'
- PID_InclusionVolumeFraction = 'PID_InclusionVolumeFraction'
- PID_InclusionYoung = 'PID_InclusionYoung'
- PID_Index = 'PID_Index'
- PID_Initial_viscosity = 'PID_Initial_viscosity'
- PID_InletFlowRate = 'PID_InletFlowRate'
- PID_InletFlowRateBackground = 'PID_InletFlowRateBackground'
- PID_InletFlowRateChamber1 = 'PID_InletFlowRateChamber1'
- PID_InletFlowRateChamber2 = 'PID_InletFlowRateChamber2'
- PID_InletFlowRateChamber3 = 'PID_InletFlowRateChamber3'
- PID_InletFlowRateSolvent = 'PID_InletFlowRateSolvent'
- PID_InletTemperature = 'PID_InletTemperature'
- PID_InletTemperatureChamber1 = 'PID_InletTemperatureChamber1'
- PID_InletTemperatureChamber2 = 'PID_InletTemperatureChamber2'
- PID_InletTemperatureChamber3 = 'PID_InletTemperatureChamber3'
- PID_Interaction_parameter = 'PID_Interaction_parameter'
- PID_Interface_width = 'PID_Interface_width'
- PID_InverseCumulativeDist = 'PID_InverseCumulativeDist'
- PID_Ion_valence_effect = 'PID_Ion_valence_effect'
- PID_KPI01 = 'PID_KPI01'
- PID_Kinematic_viscosity = 'PID_Kinematic_viscosity'
- PID_LEDCCT = 'PID_LEDCCT'
- PID_LEDColor_x = 'PID_LEDColor_x'
- PID_LEDColor_y = 'PID_LEDColor_y'
- PID_LEDRadiantPower = 'PID_LEDRadiantPower'
- PID_LEDSpectrum = 'PID_LEDSpectrum'
- PID_LUMO = 'PID_LUMO'
- PID_Label = 'PID_Label'
- PID_Lattice_parameter = 'PID_Lattice_parameter'
- PID_Lattice_spacing = 'PID_Lattice_spacing'
- PID_Lattice_vectors = 'PID_Lattice_vectors'
- PID_Length = 'PID_Length'
- PID_LennardJonesEnergy = 'PID_LennardJonesEnergy'
- PID_Linear_constant = 'PID_Linear_constant'
- PID_LocalBendingStiffness = 'PID_LocalBendingStiffness'
- PID_MOLECULAR_WEIGHT = 'PID_MOLECULAR_WEIGHT'
- PID_Magnitude = 'PID_Magnitude'
- PID_Major = 'PID_Major'
- PID_Mass = 'PID_Mass'
- PID_Mass_density = 'PID_Mass_density'
- PID_Material = 'PID_Material'
- PID_MaterialCard = 'PID_MaterialCard'
- PID_MaterialList = 'PID_MaterialList'
- PID_MaterialPlot = 'PID_MaterialPlot'
- PID_Material_type = 'PID_Material_type'
- PID_MatrixDensity = 'PID_MatrixDensity'
- PID_MatrixOgdenExponent = 'PID_MatrixOgdenExponent'
- PID_MatrixOgdenModulus = 'PID_MatrixOgdenModulus'
- PID_MatrixPoisson = 'PID_MatrixPoisson'
- PID_MatrixYoung = 'PID_MatrixYoung'
- PID_Maximum_Courant_number = 'PID_Maximum_Courant_number'
- PID_Maximum_viscosity = 'PID_Maximum_viscosity'
- PID_MeltingEnthalpy = 'PID_MeltingEnthalpy'
- PID_MeltingTemperature = 'PID_MeltingTemperature'
- PID_Minimum_viscosity = 'PID_Minimum_viscosity'
- PID_Minor = 'PID_Minor'
- PID_MolarMass = 'PID_MolarMass'
- PID_Molar_volume = 'PID_Molar_volume'
- PID_Moment_inertia = 'PID_Moment_inertia'
- PID_Momentum = 'PID_Momentum'
- PID_Name_UC = 'PID_Name_UC'
- PID_None = 'PID_None'
- PID_NrOfComponents = 'PID_NrOfComponents'
- PID_NumberOfFluorescentParticles = 'PID_NumberOfFluorescentParticles'
- PID_NumberOfRays = 'PID_NumberOfRays'
- PID_Number_of_cores = 'PID_Number_of_cores'
- PID_Number_of_physics_states = 'PID_Number_of_physics_states'
- PID_Number_of_time_steps = 'PID_Number_of_time_steps'
- PID_Occupancy = 'PID_Occupancy'
- PID_Order_parameter = 'PID_Order_parameter'
- PID_Original_position = 'PID_Original_position'
- PID_OutletVelocity = 'PID_OutletVelocity'
- PID_POLYDISPERSITY_INDEX = 'PID_POLYDISPERSITY_INDEX'
- PID_PRESSURE = 'PID_PRESSURE'
- PID_ParticleMu = 'PID_ParticleMu'
- PID_ParticleNumberDensity = 'PID_ParticleNumberDensity'
- PID_ParticleRefractiveIndex = 'PID_ParticleRefractiveIndex'
- PID_ParticleSigma = 'PID_ParticleSigma'
- PID_Patch = 'PID_Patch'
- PID_Phase_interaction_strength = 'PID_Phase_interaction_strength'
- PID_PhosphorEfficiency = 'PID_PhosphorEfficiency'
- PID_PoissonRatio = 'PID_PoissonRatio'
- PID_PoissonRatio12 = 'PID_PoissonRatio12'
- PID_PoissonRatio13 = 'PID_PoissonRatio13'
- PID_PoissonRatio23 = 'PID_PoissonRatio23'
- PID_Poisson_ratio = 'PID_Poisson_ratio'
- PID_PolymerConcentration = 'PID_PolymerConcentration'
- PID_Position = 'PID_Position'
- PID_Potential_energy = 'PID_Potential_energy'
- PID_Power_law_index = 'PID_Power_law_index'
- PID_Pressure = 'PID_Pressure'
- PID_Probability_coefficient = 'PID_Probability_coefficient'
- PID_ProcessPressure = 'PID_ProcessPressure'
- PID_Radius = 'PID_Radius'
- PID_Reference_density = 'PID_Reference_density'
- PID_RefractiveIndex = 'PID_RefractiveIndex'
- PID_Relative_velocity = 'PID_Relative_velocity'
- PID_Relaxation_time = 'PID_Relaxation_time'
- PID_Restitution_coefficient = 'PID_Restitution_coefficient'
- PID_Rolling_friction = 'PID_Rolling_friction'
- PID_SMILE_FILLER_MOLECULAR_STRUCTURE = 'PID_SMILE_FILLER_MOLECULAR_STRUCTURE'
- PID_SMILE_MODIFIER_MOLECULAR_STRUCTURE = 'PID_SMILE_MODIFIER_MOLECULAR_STRUCTURE'
- PID_SMILE_MOLECULAR_STRUCTURE = 'PID_SMILE_MOLECULAR_STRUCTURE'
- PID_Scaling_coefficient = 'PID_Scaling_coefficient'
- PID_ScatteringCrossSections = 'PID_ScatteringCrossSections'
- PID_Self_Diffusivity = 'PID_Self_Diffusivity'
- PID_Shape_center = 'PID_Shape_center'
- PID_Shape_length = 'PID_Shape_length'
- PID_Shape_radius = 'PID_Shape_radius'
- PID_Shape_side = 'PID_Shape_side'
- PID_ShearInPlaneStiffness = 'PID_ShearInPlaneStiffness'
- PID_ShearModulus12 = 'PID_ShearModulus12'
- PID_ShearModulus13 = 'PID_ShearModulus13'
- PID_ShearModulus23 = 'PID_ShearModulus23'
- PID_ShearOutOfPlaneStiffness = 'PID_ShearOutOfPlaneStiffness'
- PID_Simulation_domain_dimensions = 'PID_Simulation_domain_dimensions'
- PID_Simulation_domain_origin = 'PID_Simulation_domain_origin'
- PID_Size = 'PID_Size'
- PID_Smoothing_length = 'PID_Smoothing_length'
- PID_Sphericity = 'PID_Sphericity'
- PID_Status = 'PID_Status'
- PID_Steady_state = 'PID_Steady_state'
- PID_Stiffness = 'PID_Stiffness'
- PID_Strain_tensor = 'PID_Strain_tensor'
- PID_Stress_tensor = 'PID_Stress_tensor'
- PID_SubstrateTemperature = 'PID_SubstrateTemperature'
- PID_SurfaceTension = 'PID_SurfaceTension'
- PID_Surface_tension = 'PID_Surface_tension'
- PID_Symmetry_lattice_vectors = 'PID_Symmetry_lattice_vectors'
- PID_TEMPERATURE = 'PID_TEMPERATURE'
- PID_TRANSITION_TEMPERATURE = 'PID_TRANSITION_TEMPERATURE'
- PID_Temperature = 'PID_Temperature'
- PID_ThermalAccomodation = 'PID_ThermalAccomodation'
- PID_Thermodynamic_ensemble = 'PID_Thermodynamic_ensemble'
- PID_Thickness = 'PID_Thickness'
- PID_Time = 'PID_Time'
- PID_Time_step = 'PID_Time_step'
- PID_TinflowBackground = 'PID_TinflowBackground'
- PID_TinflowModelID = 'PID_TinflowModelID'
- PID_TinflowModelType = 'PID_TinflowModelType'
- PID_TinflowPolymer = 'PID_TinflowPolymer'
- PID_TinflowReportFile = 'PID_TinflowReportFile'
- PID_TinflowResultFile = 'PID_TinflowResultFile'
- PID_TinflowSolvent = 'PID_TinflowSolvent'
- PID_Torque = 'PID_Torque'
- PID_UserTimeStep = 'PID_UserTimeStep'
- PID_Van_der_Waals_radius = 'PID_Van_der_Waals_radius'
- PID_Variable = 'PID_Variable'
- PID_Vector = 'PID_Vector'
- PID_Velocity = 'PID_Velocity'
- PID_Viscosity = 'PID_Viscosity'
- PID_Volume = 'PID_Volume'
- PID_Volume_fraction = 'PID_Volume_fraction'
- PID_Volume_fraction_gradient = 'PID_Volume_fraction_gradient'
- PID_Width = 'PID_Width'
- PID_YoungModulus1 = 'PID_YoungModulus1'
- PID_YoungModulus2 = 'PID_YoungModulus2'
- PID_YoungModulus3 = 'PID_YoungModulus3'
- PID_Young_modulus = 'PID_Young_modulus'
- PID_Zeta_potential = 'PID_Zeta_potential'
- PID_conductivity_green_phosphor = 'PID_conductivity_green_phosphor'
- PID_conductivity_red_phosphor = 'PID_conductivity_red_phosphor'
- PID_conventionCoefficient = 'PID_conventionCoefficient'
- PID_conventionExternalTemperature = 'PID_conventionExternalTemperature'
- PID_dirichletBC = 'PID_dirichletBC'
- PID_effective_conductivity = 'PID_effective_conductivity'
- PID_maxDisplacement = 'PID_maxDisplacement'
- PID_maxMisesStress = 'PID_maxMisesStress'
- PID_maxPrincipalStress = 'PID_maxPrincipalStress'
- PID_mean_radius_green_phosphor = 'PID_mean_radius_green_phosphor'
- PID_mean_radius_red_phosphor = 'PID_mean_radius_red_phosphor'
- PID_standard_deviation_green_phosphor = 'PID_standard_deviation_green_phosphor'
- PID_standard_deviation_red_phosphor = 'PID_standard_deviation_red_phosphor'
- PID_transient_simulation_time = 'PID_transient_simulation_time'
- PID_volume_fraction_green_phosphor = 'PID_volume_fraction_green_phosphor'
- PID_volume_fraction_red_phosphor = 'PID_volume_fraction_red_phosphor'
- PSID_ParticlePositions = 'PSID_ParticlePositions'
- class mupif.DataList(*args, metadata: BaseMeta = BaseMeta(), objs: List[Data], dataID: DataID | None = DataID.ID_None)
Bases:
Data- getDataID()
- getItem(i)
- getItems()
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dataID': FieldInfo(annotation=Union[DataID, NoneType], required=False, default=<DataID.ID_None: 'ID_None'>), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'objs': FieldInfo(annotation=List[Data], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- classmethod objs_validator(v)
- class mupif.DbDictable
Bases:
BareData- static from_db_dict(d, dialect: Literal['edm'] | None = None)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- to_db_dict(dialect: Literal['edm'] | None = None) dict[str, Any]
- to_db_dict_impl()
- class mupif.DirTemporalField(*a, metadata: BaseMeta = BaseMeta(), fieldMeta: List[_FieldMetadata] = [], dir: str)
Bases:
TemporalFieldImplementation of TemporalField which stored all data in local files
- addField(field, userMetadata)
- dir: str
- evaluate(time: ~astropy.units.quantity.Quantity, positions, eps: float = 0.0, epsTime=<Quantity 0. s>)
- fieldMeta: List[_FieldMetadata]
- getCachedTimes()
- getField(time: ~astropy.units.quantity.Quantity, epsTime=<Quantity 0. s>)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dir': FieldInfo(annotation=str, required=True), 'fieldMeta': FieldInfo(annotation=List[_FieldMetadata], required=False, default=[]), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta())}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- timeMetadata(time, epsTime=<Quantity 0. s>) dict
- class mupif.Field(*, metadata: ~mupif.field.FieldMeta = FieldMeta(Units=None, Type='mupif.field.Field', Type_ID=None, FieldType=None, ValueType=None), quantity: ~astropy.units.quantity.Quantity | ~mupif.units.RefQuantity, valueType: ~mupif.mupifquantity.ValueType = ValueType.Scalar, fieldID: ~mupif.dataid.DataID, time: ~astropy.units.quantity.Quantity = <Quantity 0. s>, mesh: ~mupif.mesh.Mesh, fieldType: ~mupif.field.FieldType = FieldType.FT_vertexBased)
Bases:
FieldBase,HeavyConvertibleRepresentation of field. Field is a scalar, vector, or tensorial quantity defined on a spatial domain. The field, however is assumed to be fixed at certain time. The field can be evaluated in any spatial point belonging to underlying domain.
Derived classes will implement fields defined on common discretizations, like fields defined on structured/unstructured FE meshes, FD grids, etc.
- __init__(**kw)
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.
- _evaluate(position: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)] | ~astropy.units.quantity.Quantity, eps)
Evaluates the receiver at a single spatial position.
- Parameters:
position (tuple) – 1D/2D/3D position vector
eps (float) – Optional tolerance
- Returns:
field value
- Return type:
tuple of doubles
Note
This method has some issues related to https://sourceforge.net/p/mupif/tickets/22/ .
- copyToHeavy(h5grp)
- dataDigest()
- evaluate(positions: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)] | ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)] | ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3, *], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)] | ~astropy.units.quantity.Quantity, eps: float = 0.0)
Evaluates the receiver at given spatial position(s).
- Parameters:
positions (tuple, a list of tuples) – 1D/2D/3D position vectors
eps (float) – Optional tolerance for probing whether the point belongs to a cell (should really not be used)
- Returns:
field value(s)
- Return type:
units.Quantity with given value or tuple of values
- field2Image2DBlock()
Block an open window from matPlotLib. Waits until closed.
- getCellValue(cellID)
Returns the value associated with a given cell.
- Parameters:
cellID (int) – Cell identifier
- Returns:
The value
- Return type:
units.Quantity
- getDataID()
Returns DataID, e.g. FID_Displacement, FID_Temperature.
- Returns:
Returns field DataID
- Return type:
- getFieldID()
Returns DataID, e.g. FID_Displacement, FID_Temperature.
- Returns:
Returns field ID
- Return type:
- getFieldIDName()
Returns name of the field.
- Returns:
Returns fieldID name
- Return type:
string
- getFieldType()
Returns receiver field type (values specified as vertex or cell values)
- Returns:
Returns fieldType id
- Return type:
- getMartixForTensor(values)
Reshape values to a list with 3x3 arrays. Usable for VTK export.
- Parameters:
values (list) – List containing tuples of 9 values, e.g. [(1,2,3,4,5,6,7,8,9), (1,2,3,4,5,6,7,8,9), …]
- Returns:
List containing 3x3 matrices for each tensor
- Return type:
list
- getQuantity()
- getRecord(componentID)
Return value in one point (cell, vertex or similar)
- getRecordQuantity(componentID)
Return value in one point (cell, vertex or similar)
- getRecordSize()
Return the number of scalars per value, depending on
valueTypepassed when constructing the instance.- Returns:
number of scalars (1,3,9 respectively for scalar, vector, tensor)
- Return type:
int
- getTime()
Get time of the field.
- Returns:
Time of field data
- Return type:
units.Quantity
- getValue()
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- getVertexValue(vertexID)
Returns the value associated with a given vertex.
- Parameters:
vertexID (int) – Vertex identifier
- Returns:
The value
- Return type:
units.Quantity
- inUnitsOf(*units)
Should return a new instance. As deep copy is expensive, this operation should be avoided. Better to use convertToUnits method performing in place conversion.
- static makeFromHdf5(*, fileName: str = None, group: str = 'component1/part1', h5group=None, indices: List[int] | None = None, heavy=False, h5own=False)
Restore Fields from HDF5 file.
- Parameters:
fileName (str) – HDF5 file
group (str) – HDF5 group the data will be read from (IOError is raised if the group does not exist).
h5group –
indices –
- Returns:
list of new
Fieldinstances- Return type:
Note
This method has not been tested yet.
- static makeFromHdf5_groups(*, fieldGrp, meshGrp=None, meshCache=None, heavy=False, h5own=False)
- classmethod makeFromHeavy(*, h5grp, indices)
- static makeFromMeshioMesh(input: str | ~meshio._mesh.Mesh, unit: dict[str, astropy.units.core.Unit], time: ~astropy.units.quantity.Quantity = <Quantity 0. s>) List[Field]
- static makeFromVtkFile(filename: str, units: dict[str, astropy.units.core.Unit] = {}, fieldIDs: dict[str, mupif.dataid.DataID] = {}, time: ~astropy.units.quantity.Quantity = <Quantity 0. s>)
- merge(field)
Merges the receiver with given field together. Both fields should be on different parts of the domain (can also overlap), but should refer to same underlying discretization, otherwise unpredictable results can occur.
- Parameters:
field (Field) – given field to merge with.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'fieldID': FieldInfo(annotation=DataID, required=True), 'fieldType': FieldInfo(annotation=FieldType, required=False, default=<FieldType.FT_vertexBased: 1>), 'mesh': FieldInfo(annotation=Mesh, required=True), 'metadata': FieldInfo(annotation=FieldMeta, required=False, default=FieldMeta(Units=None, Type='mupif.field.Field', Type_ID=None, FieldType=None, ValueType=None)), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'time': FieldInfo(annotation=Quantity, required=False, default=<Quantity 0. s>), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- plot2D(plane='xy', title=None, fieldComponent=0, warpField=None, warpScale=0.0, fileName=None, show=False, colorbar='horizontal')
Plots and/or saves 2D image using a matplotlib library. Works for structured and unstructured 2D/3D fields. 2D/3D fields need to define plane. This method gives only basic viewing options, for aesthetic and more elaborated output use e.g. VTK field export with postprocessors such as ParaView or Mayavi. Idea from https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html#id1
- Parameters:
plane (str) – what plane to extract from field, valid values are ‘xy’, ‘xz’, ‘yz’
fieldComponent (int) – component of the field
colorbar (str) – color bar details. Valid values ‘’ for no colorbar, ‘vertical’ or ‘horizontal’
title (str) – title
fileName (str) – if nonempty, a filename is written to the disk, usually png, pdf, ps, eps and svg are supported
show (bool) – if the plot should be showed
warpField (Field) – vector field to wrap geometry
warpScale (float) – warping scale
- Returns:
handle to matplotlib figure
- property q
- quantity: Union[units.Quantity, units.RefQuantity]
- setRecord(componentID, value)
Sets the value associated with a given component (vertex or cell).
- Parameters:
componentID (int) – An identifier of a component: vertexID or cellID
value (tuple) – Value to be set for a given component, should have the same units as receiver
- toHdf5(*, fileName: str = None, groupName='component1/part1', h5group=None, heavyMesh=False)
Dump field to HDF5, in a simple format suitable for interoperability (TODO: document).
- Parameters:
fileName (str) – HDF5 file
groupName (str) –
h5group (str) – HDF5 group the data will be saved under.
The HDF hierarchy is like this:
group | +--- meshes | +----25aa0aa04457 | | +--- [vertex_coords] | | +--- [cell_types] | | \--- [cell_vertices] | +--- 17809e2b86ea | +--- [vertex_coords] | +--- [cell_types] | \--- [cell_vertices] +--- fields +--- 1 | +--- -> meshes/25aa0aa04457 | \--- [vertex_values] +--- 2 | +--- -> meshes/17809e2b86ea | \--- [vertex_values] +--- 3 +--- -> meshes/17809e2b86ea \--- [cell_values]
where
plainnames are HDF (sub)groups,[bracketed]names are datasets,{name=value}are HDF attributes,->prefix indicated HDF5 hardlink (transparent to the user); numerical suffixes (_01, …) are auto-allocated. Mesh objects are hardlinked using HDF5 hardlinks if an identical mesh is already stored in the group, based on hexdigest of its full data.Note
This method has not been tested yet. The format is subject to future changes.
- toHdf5Group(fieldGrp, meshLink=None)
- toHdf5_split_files(fieldPrefix: str, meshPrefix: str, flat=True, heavy=False)
- toMeshioMesh()
- property unit
- property value
- class mupif.FieldBase(*, metadata: ~mupif.field.FieldMeta = FieldMeta(Units=None, Type='mupif.field.Field', Type_ID=None, FieldType=None, ValueType=None), quantity: ~astropy.units.quantity.Quantity | ~mupif.units.RefQuantity, valueType: ~mupif.mupifquantity.ValueType = ValueType.Scalar, fieldID: ~mupif.dataid.DataID, time: ~astropy.units.quantity.Quantity = <Quantity 0. s>)
Bases:
MupifQuantity- dataDigest(*args)
- evaluate(positions, eps: float = 0.0)
Evaluates the receiver at given spatial position(s).
- Parameters:
positions (tuple, a list of tuples) – 1D/2D/3D position vectors
eps (float) – Optional tolerance for probing whether the point belongs to a cell (should really not be used)
- Returns:
field value(s)
- Return type:
units.Quantity with given value or tuple of values
- getDataID()
Returns DataID, e.g. FID_Displacement, FID_Temperature.
- Returns:
Returns field DataID
- Return type:
- getFieldID()
Returns DataID, e.g. FID_Displacement, FID_Temperature.
- Returns:
Returns field DataID
- Return type:
- getFieldIDName()
Returns name of the field.
- Returns:
Returns DataID name
- Return type:
string
- getQuantity()
- getTime()
Get time of the field.
- Returns:
Time of field data
- Return type:
units.Quantity
- getValue()
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'fieldID': FieldInfo(annotation=DataID, required=True), 'metadata': FieldInfo(annotation=FieldMeta, required=False, default=FieldMeta(Units=None, Type='mupif.field.Field', Type_ID=None, FieldType=None, ValueType=None)), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'time': FieldInfo(annotation=Quantity, required=False, default=<Quantity 0. s>), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- property q
- quantity: Union[units.Quantity, units.RefQuantity]
- property unit
- property value
- class mupif.FieldType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
IntEnumRepresent the supported values of FieldType, i.e. FT_vertexBased or FT_cellBased.
- FT_cellBased = 2
- FT_vertexBased = 1
- as_integer_ratio()
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()
Returns self, the complex conjugate of any int.
- denominator
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag
the imaginary part of a complex number
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class mupif.Function(*, metadata={}, dataID: DataID, valueType: ValueType, unit: Unit, inputs: dict = None)
Bases:
DataRepresents a function.
Usage of class Function for data transfers between codes as with Field or Property is deprecated. It is not supposed for data transfers any more, thus becomes an auxiliary class.
Function is an object defined by mathematical expression. Function can depend on spatial position and time. Derived classes should implement evaluate service by providing a corresponding expression.
Example: f(x,t)=sin(2*3.14159265*x(1)/10.)
- __init__(*, metadata={}, **kw)
Initializes the function.
- Parameters:
funcID (DataID) – function ID, e.g. FuncID_ProbabilityDistribution
objectID (int) – Optional ID of associated subdomain, default 0
- evaluate(p)
Evaluates the function for given parameters packed as a dictionary.
A dictionary is container type that can store any number of Python objects, including other container types. Dictionaries consist of pairs (called items) of keys and their corresponding values.
Example: p={‘x’:(1,2,3)*mupif.U.m, ‘t’:0.005*mupif.U.s} initializes parameter dictionary contaning vector quantity under ‘x’ key and scalar quantity under ‘t’ key.
- Parameters:
p (dictionary) – Dictionary containing function arguments (number and type depends on particular function)
- Returns:
Function value evaluated at given position and time
- Return type:
- getDataID()
Obtain function’s ID.
- Returns:
Returns receiver’s ID.
- Return type:
int
- inputs: dict
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dataID': FieldInfo(annotation=DataID, required=True), 'inputs': FieldInfo(annotation=dict, required=False, default_factory=dict), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'unit': FieldInfo(annotation=Unit, required=True), 'valueType': FieldInfo(annotation=ValueType, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.GaussIntegrationRule
Bases:
IntegrationRuleGauss integration rule.
- getIntegrationPoints(cgt, npt)
- getRequiredNumberOfPoints(cgt, order)
- class mupif.Hdf5OwningRefQuantity(*, metadata: BaseMeta = BaseMeta(), h5path: str = '', h5uri: str | None = None, mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] = 'readonly', pyroIds: List[str] = [], dataset: Dataset | None = None, h5loc: str = '/quantity')
Bases:
Hdf5RefQuantity,HeavyDataBaseQuantity stored in HDF5 dataset, managing the HDF5 file itself.
- ModeChoice
alias of
Literal[‘readonly’, ‘readwrite’, ‘overwrite’, ‘create’, ‘create-memory’, ‘copy-readwrite’]
- class QuantityRowAccessor(refq)
Bases:
object
- class ValueRowAccessor(refq)
Bases:
object
- allocateDataset(*, shape, unit, **kw)
- cloneHandle(newPath: str = '')
Return clone of the handle; the underlying storage is copied into newPath (or a temporary file, if not given). All handle attributes (besides
h5path) are preserved.
- closeData()
Flush and close the backing HDF5 file;
unregister all contexts from Pyro (if registered)
- dataset: Annotated[typing.Optional[h5py.Dataset], pydantic.Field(exclude=True)]
- exposeData()
If self is registered in a Pyro daemon, the underlying HDF5 file will be exposed as well. This modifies the
h5uriattribute which causes transparent download of the HDF5 file when theHeavyDataBaseobject is reconstructed remotely by Pyro (e.g. by usingBareData.copyRemote).
- h5loc: str
- h5path: str
- h5uri: Optional[str]
- makeRef()
- mode: HeavyDataBase_ModeChoice
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dataset': FieldInfo(annotation=Union[Dataset, NoneType], required=False, default=None, exclude=True), 'h5loc': FieldInfo(annotation=str, required=False, default='/quantity'), 'h5path': FieldInfo(annotation=str, required=False, default=''), 'h5uri': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'mode': FieldInfo(annotation=Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'], required=False, default='readonly'), 'pyroIds': FieldInfo(annotation=List[str], required=False, default=[], exclude=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- moveStorage(new_h5path)
Moves underlying storage in the filesystem to the new path new_h5path, and sets the
h5pathattribute to the new path.
- property ndim
- openData(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- openStorage(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- pyroIds: List[str]
- property quantity
- reopenData(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- repack()
Repack the underlying storage (experimental, untested). Data must not be open.
- property shape
- toQuantity()
Convert to “normal” (in-memory) quantity
- property unit
- property value
- class mupif.Hdf5RefQuantity(*, unit=None, dataset: Dataset | None = None)
Bases:
RefQuantityQuantity stored in HDF5 dataset, the HDF5 file being managed somewhere else.
- class QuantityRowAccessor(refq)
Bases:
object
- class ValueRowAccessor(refq)
Bases:
object
- dataset: Dataset | None
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dataset': FieldInfo(annotation=Union[Dataset, NoneType], required=False, default=None, exclude=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- property ndim
- property quantity
- property shape
- property unit
- property value
- class mupif.HeavyConvertible
Bases:
BaseModel- copyToHeavy(*, h5grp)
- classmethod makeFromHeavy(*, h5grp, indices)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.HeavyDataBase(*, metadata: BaseMeta = BaseMeta(), h5path: str = '', h5uri: str | None = None, mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] = 'readonly', pyroIds: List[str] = [])
Bases:
DataBase class for various HDF5-backed objects with automatic HDF5 transfer when copied to remote location. This class is to be used internally only.
- ModeChoice
alias of
Literal[‘readonly’, ‘readwrite’, ‘overwrite’, ‘create’, ‘create-memory’, ‘copy-readwrite’]
- allocateDataset(*, h5loc, shape, **kw)
- cloneHandle(newPath: str = '')
Return clone of the handle; the underlying storage is copied into newPath (or a temporary file, if not given). All handle attributes (besides
h5path) are preserved.
- closeData()
Flush and close the backing HDF5 file;
unregister all contexts from Pyro (if registered)
- exposeData()
If self is registered in a Pyro daemon, the underlying HDF5 file will be exposed as well. This modifies the
h5uriattribute which causes transparent download of the HDF5 file when theHeavyDataBaseobject is reconstructed remotely by Pyro (e.g. by usingBareData.copyRemote).
- h5path: str
- h5uri: str | None
- mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'h5path': FieldInfo(annotation=str, required=False, default=''), 'h5uri': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'mode': FieldInfo(annotation=Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'], required=False, default='readonly'), 'pyroIds': FieldInfo(annotation=List[str], required=False, default=[], exclude=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- moveStorage(new_h5path)
Moves underlying storage in the filesystem to the new path new_h5path, and sets the
h5pathattribute to the new path.
- openStorage(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- pyroIds: List[str]
- repack()
Repack the underlying storage (experimental, untested). Data must not be open.
- class mupif.HeavyStruct(*, metadata: BaseMeta = BaseMeta(), h5path: str = '', h5uri: str | None = None, mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] = 'readonly', pyroIds: List[str] = [], h5group: str = '/', schemaName: str | None = None, schemasJson: str | None = None, id: DataID = DataID.ID_None)
Bases:
HeavyDataBaseDefine semantic access to potentially large (that is, larger than RAM) structured data, both locally and over the network. The data structure is defined using schemas in JSON, where each schema defines table-like structure with rows of data, each row possibly further referencing another table with a different schema. The data is internally stored in a HDF5 file, which includes the schemas, making the file self-describing. JSON schema is thus only required when the data is being created, not for opening an already existing data.
mode specifies how the underlying HDF5 file (
h5path) is to be opened:readonlyonly allows reading;readwritealows reading and writing;createcreates new HDF5 file, raising an exception if the file exists already; ifh5pathis empty, a temporary file will be created automatically;overwritecreate new HDF5 file, allowing overwriting an existing file;create-memorycreate HDF5 file in RAM only; ifh5pathis non-empty, it will be written out when data is closed viacloseData(and discarded otherwise);
schemaName and schemasJson must be provided when creating new data (
overwrite,create,create-memory) and are ignored otherwise.This class can be used as context manager, in which case the
openDataandcloseDatawill be called automatically.JSON schema specification
The schema is defined as dictionary (nesting is possible). The top-level dictionary of each schema
must include
_schema(which must definenameandversion),must include
_datasetNameentries,may include other, regular entries, as described below; names must not be reserved names.
Reserved names are those starting with
_(underscore) plusdtype,lookupandpath.Regular entries
Regular entries are one of the following.
Computed attribute (identified via the
lookupkeyword); computed attribute must definelookup, which is a lookup table (key-value dictionary), dtype (datatype being returned from lookup) and key (descriptor of data attribute used for lookup); it may defineunit.Data attribute (identified via the
dtypekey, but not havinglookup); it must definedtypeand may defineunit,shape.subschema reference (identified by the
schemakeyword); it must defineschema(pathis optional).dictionary possibly including other regular entries (directory, creating hierarchy).
Data types
dtypespecifies datatype for the entry value using thenumpy.dtypenotation (see Data type objects), for examplef8for 8-byte (64-bit) floating-point number.Strings are stored as utf-8 encoded byte arrays (thus their storage length might be larger than number of characters). use
"dtype":"S"for variable-length strings (aimplies"shape":"variable"), and"dtype":"a10"for string of maximum 10 bytes.String fields may specify delim, which is a delimiter sequence. The value will be presented as a tuple of strings to the user, interally stored as string joined by the delim. delim may be a single character or several characters. Values being set may not contain the delimiter itself. If the string is fixed-size, summary length of the string must not exceed the storage space. The value returned to the user is a tuple (read-only) to prevent in-place item modification.
shapeis a tuple specifying fixed shape: e.g."shape":(3)is rank-1 3-vector,"shape":(3,3)is rank-2 3×3 matrix and so on. The special value of"shape":"variable"denotes dynamic 1d array of givendtype.Note
Variable-length data (both strings and numerical arrays) are handled in a special way by the HDF5 storage; each (non-empty) entry has about 30b overhead, plus necessitates allocationes. If your data can always fit into a fixed-size array (such as string of maximum 20 bytes,
a20), prefer that for both performance ans storage reasons.All data are initialized to the default when constructed, which is:
NaN(not-a-number) for floating-point types (scalars and arrays),0(zero) for integer types (scalars and arrays),empty array for dynamic arrays,
empty string for both static-sized (
"dtype":"a10") and dynamic-sized ("dtype":"S") strings.
Assignments of incompatible data (which cannot be converted to the underlying storage type), including mismatched shape of arrays, will raise exception.
Units
Entries specifying
unit(which is any string astropy.units.Unit can grok) must be assigned with quantities including compatible units; the value will be converted to the schema unit before being set. The field will be returned as a Quantity (including the unit) when read back.Subschema
Subschema entries associate full (nested hierarchical) data stratucture with each table line. The entry must specify
schemaname (which must be present in the schemaRegistry argument ofHeavyStruct.openData). Thepathattribute is specified optionally (has a default value); path defines where the nested data is stored within the HDF5 file and must contain{ROW}(as string, including the curly braces) and end with/.
Accessing data
Data are accesse using Contexts, special classes abstracting away the underlying storage. They define getters (and setters) for each data level (the are called simply
get/setfollowed by capitalized entry name). Rows are selected using the usual indexing operator[index], though a whole column can be returned when index is not specified.Top contexts (on the level of the schema) define a few special methods:
resizewhich will change the number of rows; new rows will be always set to the default values. When passing the argumentreset=Truetoresize, all rows will be default-initialized.injectwill replace the current context’s data with data from another context (recursively); the routine will take care to resize structures as necessary. Schema names must be matching, and differences in schema versions will be reported as warning (it will be possible to user-define transformation for converting between different schema versions). The data exchange happens using serialized format which can be obtained and consumed usingto_dump()andfrom_dump(…)methods.
Each parent group defines a special property
schema_fragmentwhich returns the schema as Python structure; this is to allow custom entries in the schema (such as descriptions or ontology mappings) to be accessed by the user.schema org.mupif.sample.atom
identity:get{capitalize(key)}():element:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: ≤ {dt.itemsize} charsatomicNumber:get{capitalize(key)}(): dtype:int64, read-only: table look-up byidentity.elementatomicMass:get{capitalize(key)}(): dtype:float32, unit:u, read-only: table look-up byidentity.element
properties:get{capitalize(key)}():physical:get{capitalize(key)}():partialCharge:get{capitalize(key)}():neutral:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:e, default:nananion:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:e, default:nancation:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:e, default:nan
polarizability:get{capitalize(key)}():neutral:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:s4 Angstrom2 / kg, default:nananion:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:s4 Angstrom2 / kg, default:nancation:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:s4 Angstrom2 / kg, default:nan
topology:get{capitalize(key)}():parent:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:int64, default:0type:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: dynamicname:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: dynamicposition:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3], dtype:float64, unit:Angstrom, default:nanvelocity:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3], dtype:float64, unit:Angstrom / ps, default:nanstructure:get{capitalize(key)}(),set{capitalize(key)}(…): shape: dynamic, dtype:[int64,…]
schema org.mupif.sample.molecule
identity:get{capitalize(key)}():chemicalName:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: dynamicmolecularWeight:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:u, default:nan
properties:get{capitalize(key)}():electrical:get{capitalize(key)}():HOMO:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nanLUMO:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nansiteEnergy:get{capitalize(key)}():orbital:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nanelectrostatic:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nanpolarization:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nan
transferIntegrals:get{capitalize(key)}(),set{capitalize(key)}(…): shape: dynamic, dtype:[float64,…]reorganizationEnergyInternal:get{capitalize(key)}():anion:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nancation:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nan
physical:get{capitalize(key)}():polarizability:get{capitalize(key)}():neutral:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3×3], dtype:float64, unit:s4 Angstrom2 / kg, default:nananion:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3×3], dtype:float64, unit:s4 Angstrom2 / kg, default:nancation:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3×3], dtype:float64, unit:s4 Angstrom2 / kg, default:nan
chemical:get{capitalize(key)}():
topology:get{capitalize(key)}():parent:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:int64, unit:none, default:0centerOfMass:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3], dtype:float64, unit:Angstrom, default:nansymmetryAxis:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3], dtype:float64, unit:Angstrom, default:nanstructureNeighbors:get{capitalize(key)}(),set{capitalize(key)}(…): shape: dynamic, dtype:[int64,…]
implementation:get{capitalize(key)}():forceFieldType:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: dynamic
atoms:get{capitalize(key)}(): nested data at{path}, schema{schema}.
schema org.mupif.sample.grain
identity:get{capitalize(key)}():material:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: dynamic
properties:get{capitalize(key)}():eletrical:get{capitalize(key)}():freeElectrons:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:int64, unit:none, default:0freeHoles:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:int64, unit:none, default:0
physical:get{capitalize(key)}():reorganizationEnergyExternal:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:float64, unit:eV, default:nan
chemical:get{capitalize(key)}():symmetry:get{capitalize(key)}(),set{capitalize(key)}(…): named enumeration stored as {dtype.name}: none (v), axial (v), periodic (v), translational (v), rotational (v)
topology:get{capitalize(key)}():parent:get{capitalize(key)}(),set{capitalize(key)}(…): dtype:int64, default:0cellSize:get{capitalize(key)}(),set{capitalize(key)}(…): shape: [3], dtype:float64, unit:m, default:nan
implementation:get{capitalize(key)}():boundaryCondition:get{capitalize(key)}(),set{capitalize(key)}(…): dtype: string (utf-8 encoded), shape: dynamic
molecules:get{capitalize(key)}(): nested data at{path}, schema{schema}.
- ModeChoice
alias of
Literal[‘readonly’, ‘readwrite’, ‘overwrite’, ‘create’, ‘create-memory’, ‘copy-readwrite’]
- class TopContext(h5group: Any, pyroIds: list, schemaRegistry: dict, dataset: Any = None)
Bases:
objectThis class is for internal use only. It is the return type of
HeavyStruct.openDataand others.- dataset: Any = None
- h5group: Any
- pyroIds: list
- schemaRegistry: dict
- allocateDataset(*, h5loc, shape, **kw)
- cloneHandle(newPath: str = '')
Return clone of the handle; the underlying storage is copied into newPath (or a temporary file, if not given). All handle attributes (besides
h5path) are preserved.
- closeData()
Flush and close the backing HDF5 file;
unregister all contexts from Pyro (if registered)
- exposeData()
If self is registered in a Pyro daemon, the underlying HDF5 file will be exposed as well. This modifies the
h5uriattribute which causes transparent download of the HDF5 file when theHeavyDataBaseobject is reconstructed remotely by Pyro (e.g. by usingBareData.copyRemote).
- getDataID()
- getSchemaName()
- getSchemasJson()
- h5group: str
- h5path: str
- h5uri: Optional[str]
- mode: HeavyDataBase_ModeChoice
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'h5group': FieldInfo(annotation=str, required=False, default='/'), 'h5path': FieldInfo(annotation=str, required=False, default=''), 'h5uri': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'id': FieldInfo(annotation=DataID, required=False, default=<DataID.ID_None: 'ID_None'>), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'mode': FieldInfo(annotation=Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'], required=False, default='readonly'), 'pyroIds': FieldInfo(annotation=List[str], required=False, default=[], exclude=True), 'schemaName': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'schemasJson': FieldInfo(annotation=Union[str, NoneType], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- moveStorage(new_h5path)
Moves underlying storage in the filesystem to the new path new_h5path, and sets the
h5pathattribute to the new path.
- openData(mode=typing.Optional[typing.Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite']])
Return top context for the underlying HDF5 data. The context is automatically published through Pyro5 daemon, if the
HeavyStructinstance is also published (this is true recursively, for all subcontexts). The contexts are unregistered whenHeavyStruct.closeDatais called (directly or via context manager).
- openStorage(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- pyroIds: List[str]
- repack()
Repack the underlying storage (experimental, untested). Data must not be open.
- schemaName: str | None
- schemasJson: str | None
- class mupif.HeavyUnstructuredMesh(*a, mapping: Any = None, unit: str | Unit | None = None, metadata: BaseMeta = BaseMeta(), h5path: str = '', h5uri: str | None = None, mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] = 'readonly', pyroIds: List[str] = [], dim: int = 3, h5group: str = '/')
Bases:
HeavyDataBase,MeshHDF5-backed unstructured mesh with mixed topology.
Vertices and cells can be added to the mesh arbitrarily (grows dynamically).
- GRP_CELL_CONN: ClassVar[str] = 'connectivity'
- GRP_CELL_OFFSETS: ClassVar[str] = 'cellOffsets'
- GRP_FIELDS: ClassVar[str] = 'fields'
- GRP_VERTS: ClassVar[str] = 'vertices'
- ModeChoice
alias of
Literal[‘readonly’, ‘readwrite’, ‘overwrite’, ‘create’, ‘create-memory’, ‘copy-readwrite’]
- allocateDataset(*, h5loc, shape, **kw)
- appendCells(types, conn)
- static appendCells_static(h5grp, types, conn)
TODO: add to UnstructuredMesh API (and Mesh as abstract) as well
- appendVertices(coords: ndarray)
- static appendVertices_static(h5grp, dim: int, coords: ndarray)
TODO: add to UnstructuredMesh API (and Mesh as abstract) as well
- asHdf5Object(parentgroup, heavyMesh=False)
- asVtkUnstructuredGrid()
Return an object as a vtk.vtkUnstructuredMesh instance.
- Returns:
vtk
- Return type:
vtk.vtkUnstructuredGrid()
Note
This method uses the compiled vtk module (which is a wrapper atop the c++ VTK library) – in contrast to
UnstructuredMesh.getVTKRepresentation, which uses the pyvtk module (python-only implementation of VTK i/o supporting only VTK File Format version 2).
- cellLabel2Number(label: int) int
Returns local cell number corresponding to given label. If no label found, throws an exception.
- Parameters:
label (str) – Cell label
- Returns:
Cell number
- Return type:
int
- Except:
Label not found
- cells()
- cloneHandle(newPath: str = '')
Return clone of the handle; the underlying storage is copied into newPath (or a temporary file, if not given). All handle attributes (besides
h5path) are preserved.
- closeData()
Flush and close the backing HDF5 file;
unregister all contexts from Pyro (if registered)
- dataDigest()
- dim: int
- exposeData()
If self is registered in a Pyro daemon, the underlying HDF5 file will be exposed as well. This modifies the
h5uriattribute which causes transparent download of the HDF5 file when theHeavyDataBaseobject is reconstructed remotely by Pyro (e.g. by usingBareData.copyRemote).
- fromMeshioMesh(mesh, unit=None, progress=False, chunk=10000)
- static fromMeshioMesh_static(h5grp, mesh, unit=None, progress=False, chunk=10000)
- getCellLocalizer()
Get the cell localizer.
- Returns:
Returns the cell localizer.
- Return type:
- getCells()
Return all cells as 2x numpy.array; each i-th row contains vertex indices for i-th cell. Does in 2 passes, first to determine maximum number of vertices per cell (to shape the field accordingly). For cells with less vertices than the maximum, excess ones are assigned the invalid value of -1.
- Returns:
(cell_types,cell_vertices)
- Return type:
(numpy.array,numpy.array)
Note
This method has not been tested yet.
- getGlobalBBox()
- getMapping()
Get mesh mapping.
- Returns:
The mapping associated to a mesh
- Return type:
defined by API
- getNumberOfCells()
Number of cells; returns -1 if backing storage is not open.
- getNumberOfVertices()
Return number of vertices; returns -1 if backing storage is not open.
- getVertex(i)
Returns i-th vertex.
- Parameters:
i (int) – i-th vertex
- Returns:
vertex
- Return type:
- getVertices()
Return all vertex coordinates as 2D (Nx3) numpy.array; each i-th row contains 3d coordinates of the i-th vertex.
- Returns:
vertices
- Return type:
numpy.array
Note
This method has not been tested yet.
- giveVertexLocalizer()
- h5group: str
- h5path: str
- h5uri: Optional[str]
- classmethod isHere(*, h5grp)
- static load(h5path, h5loc='/', open=True)
- static makeFromHdf5group(*, h5grp)
- static makeFromMeshioMesh(mesh)
- static makeFromMeshioPointsCells(points, cells)
- makeHeavyField(*, fieldID, fieldType, valueType, unit, h5path='', dtype='f8', h5mode='create', fieldTime=<Quantity 0. s>)
Create preallocated
mupif.Fieldobject storing its data in the same HDF5 file as the mesh (self). The field dimensions are determined from fieldType (cell/vertex based, plus the number of cells/vertices of the mesh object) and valueType (size of one record). The field’s values are not assigned but allocated in the HDF5 container as a dataset.The usage looks as follows:
>>> import mupif as mp >>> with mp.HeavyUnstructuredMesh(h5path='/tmp/t3.h5',mode='overwrite') as hMesh: >>> # load mesh from somewhere >>> hMesh.fromMeshioMesh(meshio.read('...'),progress=True,chunk=1000) >>> # declare and allocate scalar field >>> pressure=hMesh.makeHeavyField(unit='Pa',fieldID=mp.DataID.FID_Pressure,fieldType=mp.FieldType.FT_cellBased,valueType=mp.ValueType.Scalar) >>> # fill field data >>> pressure.value[:]=np.loadtxt('...',comments='%',usecols=(1,)) >>> # create vector field >>> velocity=t3.makeHeavyField(unit='m/s',fieldID=mp.DataID.FID_Velocity,fieldType=mp.FieldType.FT_cellBased,valueType=mp.ValueType.Vector) >>> velocity.value[:]=np.loadtxt('...',comments='%',usecols=(1,2,3)) >>> # write XDMF (can be opened in Paraview) >>> t3.writeXDMF(xdmf='/tmp/t3.xdmf',fields=[pressure,velocity])
- mapping: Any
- mode: HeavyDataBase_ModeChoice
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dim': FieldInfo(annotation=int, required=False, default=3), 'h5group': FieldInfo(annotation=str, required=False, default='/'), 'h5path': FieldInfo(annotation=str, required=False, default=''), 'h5uri': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'mapping': FieldInfo(annotation=Any, required=False, default=None), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'mode': FieldInfo(annotation=Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'], required=False, default='readonly'), 'pyroIds': FieldInfo(annotation=List[str], required=False, default=[], exclude=True), 'unit': FieldInfo(annotation=Union[str, Unit, NoneType], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- moveStorage(new_h5path)
Moves underlying storage in the filesystem to the new path new_h5path, and sets the
h5pathattribute to the new path.
- openData(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'])
Opens the backing storage (HDF5 file) and prepares
- openStorage(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- pyroIds: List[str]
- repack()
Repack the underlying storage (experimental, untested). Data must not be open.
- toMeshioMesh()
- toMeshioPointsCells()
- unit: Optional[Union[str, units.Unit]]
- vertexLabel2Number(label: int) int
Returns local vertex number corresponding to given label. If no label found, throws an exception.
- Parameters:
label (str) – Vertex label
- Returns:
Vertex number
- Return type:
int
- Except:
Label not found
- vertices()
- writeXDMF(xdmf=None, fields=[])
Write crude XDMF file for inspection — without copying any of the heavy data.
- class mupif.IntegrationRule
Bases:
objectRepresent integration rule to be used on cells.
- __init__()
- getIntegrationPoints(cgt, npt)
Returns a list of integration points and corresponding weights.
- Parameters:
cgt (CellGeometryType) – Type of underlying cell geometry (e.g. linear triangle CGT_TRIANGLE_1)
npt (int) – Number of desired integration points
- Returns:
A list of tuples containing natural coordinates of integration point and weights, i.e. [((c1_ksi, c1_eta), weight1), ((c2_ksi, c2_eta), weight2)]
- Return type:
a list of tuples
- getRequiredNumberOfPoints(cgt, order)
Returns required number of integration points to exactly integrate polynomial of order approxOrder on a given cell type.
- Parameters:
cgt (CellGeometryType) – Type of underlying cell geometry (e.g. linear triangle CGT_TRIANGLE_1)
order (int) – Target polynomial order
- exception mupif.JobManException(*args, **kwargs)
Bases:
ModelServerException- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mupif.JobManNoResourcesException(*args, **kwargs)
Bases:
ModelServerNoResourcesException- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mupif.JobManager(*args, **kwargs)
Bases:
ModelServerBase- allocateJob(user, ticket=None)
Allocates a new job.
- Parameters:
user (str) – user name
ticket – ticket for preallocated resource, defaults to None
- Returns:
tuple (error code, None). errCode = (JOBMAN_OK, JOBMAN_ERR, JOBMAN_NO_RESOURCES). JOBMAN_OK indicates sucessfull allocation and JobID contains the PYRO name, under which the new instance is registered (composed of application name and a job number (allocated by jobmanager), ie, Miccress23). JOBMAN_ERR indicates an internal error, JOBMAN_NO_RESOURCES means that job manager is not able to allocate new instance of application (no more recources available)
- Return type:
tuple
- Except:
JobManException when allocation of new job failed
- getJobStatus(jobID)
Returns the status of the job.
- Parameters:
jobID (str) – jobID
- getJobWorkDir(jobID)
Returns working directory of a job with given ID.
- Parameters:
jobID (str) –
- Returns:
job working directory
- Return type:
str
- getModelMetadata()
- getNSName()
- getName()
- getNumberOfFreeJobs()
Returns number of free jobs to be allocated.
- getPyroFile(jobID, filename, buffSize=1024)
Returns the (remote) PyroFile representation of given file. To create local copy of file represented by PyroFile, use pyroutil.downloadPyroFile, see
pyroutil.downloadPyroFile()- Parameters:
jobID (str) – job identifier (jobID)
filename (str) – source file name (on remote server). The filename should contain only base filename, not a path, which is determined by jobManager based on jobID.
buffSize (int) –
- Returns:
PyroFile representation of given file
- Return type:
- getStatus() List[JobStatus]
- preAllocate(requirements=None)
Allows to pre-allocate(reserve) the resource. Returns ticket id (as promise) to finally allocate resource. The requirements is an optional job-man specific dictionary with additional parameters (such as number of cpus, etc). The returned ticket is valid only for fixed time period), then should expire.
- registerPyro(*, daemon, ns, uri, appName, exclusiveDaemon=False, externalDaemon=None)
Possibility to register the Pyro daemon and nameserver.
- Parameters:
daemon (Pyro5.api.Daemon) – Optional pyro daemon
ns (Pyro4.naming.Nameserver) – Optional nameserver
uri (string) – Optional URI of receiver
appName (string) –
exclusiveDaemon (bool) – Optional parameter when damon was allocated externally.
- terminate()
Terminates job manager itself.
- terminateJob(jobID)
Terminates the given job, frees the associated recources.
- Parameters:
jobID (str) – jobID
- Returns:
JOBMAN_OK indicates sucessfull termination, JOBMAN_ERR means internal error
- Return type:
str
- uploadFile(jobID, filename, pyroFile)
Uploads the given file to application server, files are uploaded to dedicated jobID directory :param str jobID: jobID :param str filename: target file name :param PyroFile pyroFile: source pyroFile
- class mupif.Localizer
Bases:
objectA Localizer is an abstract class representing an algorithm used to partition space and quicly localize the contained objects.
- delete(item)
Deletes the given object from Localizer data structure.
- Parameters:
item (object) – Object to be removed
- evaluate(functor)
Returns the list of all objects for which the functor is satisfied.
- Parameters:
functor (object) – The functor is a class which defines two methods: giveBBox() which returns an initial functor bbox and evaluate(obj) which should return True if the functor is satisfied for a given object.
- Returns:
List of all objects
- Return type:
tuple
- getItemsInBBox(bbox)
- Parameters:
bbox (BBox) – Bounding box
- Returns:
List of all objects which bbox contains and intersects
- Return type:
tuple
- insert(item)
Inserts given object to Localizer. Object is assume to provide giveBBox() method returning bounding volume if itself.
- Parameters:
item (object) – Inserted object
- class mupif.LookupTable(*, metadata={})
Bases:
Data- __init__(*, metadata={}, **kw)
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_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta())}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.MemoryLookupTable(*, metadata={}, data: List[List[float]] = [], units: List[Unit] = [], default_value: float = None, tolerance: float = 0.0001)
Bases:
LookupTable- __init__(*, metadata={}, **kw)
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.
- data: List[List[float]]
- default_value: float
- evaluate(params)
Returns the value for given parameters. :param: Quantity[] params: :rtype: Quantity
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'data': FieldInfo(annotation=List[List[float]], required=False, default=[]), 'default_value': FieldInfo(annotation=float, required=False, default=None), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'tolerance': FieldInfo(annotation=float, required=False, default=0.0001), 'units': FieldInfo(annotation=List[Unit], required=False, default=[])}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- tolerance: float
- class mupif.Mesh(*a, mapping: Any = None, unit: str | Unit | None = None)
Bases:
BareDataAbstract representation of a computational domain. Mesh contains computational cells and vertices. Derived classes represent structured, unstructured FE grids, FV grids, etc.
Mesh is assumed to provide a suitable instance of cell and vertex localizers.
- __init__(*a, **kw)
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.
- asHdf5Object(parentgroup, heavyMesh=False)
- asVtkUnstructuredGrid()
Return an object as a vtk.vtkUnstructuredMesh instance.
- Returns:
vtk
- Return type:
vtk.vtkUnstructuredGrid()
Note
This method uses the compiled vtk module (which is a wrapper atop the c++ VTK library) – in contrast to
UnstructuredMesh.getVTKRepresentation, which uses the pyvtk module (python-only implementation of VTK i/o supporting only VTK File Format version 2).
- cellLabel2Number(label: int) int
Returns local cell number corresponding to given label. If no label found, throws an exception.
- Parameters:
label (str) – Cell label
- Returns:
Cell number
- Return type:
int
- Except:
Label not found
- cells()
- getCellLocalizer()
Get the cell localizer.
- Returns:
Returns the cell localizer.
- Return type:
- getCells()
Return all cells as 2x numpy.array; each i-th row contains vertex indices for i-th cell. Does in 2 passes, first to determine maximum number of vertices per cell (to shape the field accordingly). For cells with less vertices than the maximum, excess ones are assigned the invalid value of -1.
- Returns:
(cell_types,cell_vertices)
- Return type:
(numpy.array,numpy.array)
Note
This method has not been tested yet.
- getGlobalBBox()
- getMapping()
Get mesh mapping.
- Returns:
The mapping associated to a mesh
- Return type:
defined by API
- getNumberOfCells() int
Return number of cells (finite elements).
- Returns:
The number of Cells
- Return type:
int
- getNumberOfVertices() int
Get number of vertices (nodes).
- Returns:
Number of Vertices
- Return type:
int
- getVertex(i: int) Vertex
Returns i-th vertex.
- Parameters:
i (int) – i-th vertex
- Returns:
vertex
- Return type:
- getVertices()
Return all vertex coordinates as 2D (Nx3) numpy.array; each i-th row contains 3d coordinates of the i-th vertex.
- Returns:
vertices
- Return type:
numpy.array
Note
This method has not been tested yet.
- giveVertexLocalizer()
- classmethod isHere(*, h5grp) bool
- static makeFromHdf5group(h5grp)
- static makeFromMeshioMesh(mesh)
- static makeFromMeshioPointsCells(points, cells)
- mapping: Any
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'mapping': FieldInfo(annotation=Any, required=False, default=None), 'unit': FieldInfo(annotation=Union[str, Unit, NoneType], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- toMeshioMesh()
- toMeshioPointsCells()
- unit: Optional[Union[str, units.Unit]]
- vertexLabel2Number(label: int) int
Returns local vertex number corresponding to given label. If no label found, throws an exception.
- Parameters:
label (str) – Vertex label
- Returns:
Vertex number
- Return type:
int
- Except:
Label not found
- vertices()
- class mupif.MeshIterator(mesh, type)
Bases:
objectClass implementing iterator on Mesh components (vertices, cells).
- __init__(mesh, type)
Constructor.
- Parameters:
mesh (Mesh) – Given mesh
type (int) – Type of mesh, e.g. VERTICES or CELLS
- __iter__()
- Returns:
Itself
- Return type:
- __next__()
- Returns:
Returns next Mesh components.
- Return type:
- class mupif.Model(*, metadata: None | dict | BaseMeta = None, pyroDaemon: Any | None = None, exclusiveDaemon: bool = False, pyroNS: str | None = None, pyroURI: str | None = None, appName: str | None = None, workDir: str = '', **kw)
Bases:
ProcessAn abstract class representing an application and its interface (API).
The purpose of this class is to define abstract services for data exchange and steering. This interface has to be implemented/provided by any application. The data exchange is performed by the means of new data types introduced in the framework, namely properties and fields. New abstract data types (properties, fields) allow to hide all implementation details related to discretization and data storage.
- __init__(*, metadata: None | dict | BaseMeta = None, **kw)
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.
- appName: str | None
- exclusiveDaemon: bool
- finishStep(tstep)
Called after a global convergence within a time step is achieved.
- Parameters:
tstep (timestep.TimeStep) – Solution step
- get(objectTypeID, time=None, objectID='')
Returns the requested object at given time. Object is identified by id.
- Parameters:
objectTypeID (DataID) – Identifier of the object
time (Physics.PhysicalQuantity) – Target time
objectID (str) – Identifies object with objectID (optional, default 0)
- Returns:
Returns requested object.
- getAPIVersion()
- Returns:
Returns the supported API version
- Return type:
str, int
- getApplicationSignature()
Get application signature.
- Returns:
Returns the application identification
- Return type:
str
- getAssemblyTime(tstep)
Returns the assembly time related to given time step. The registered fields (inputs) should be evaluated in this time.
- Parameters:
tstep (timestep.TimeStep) – Solution step
- Returns:
Assembly time
- Return type:
Physics.PhysicalQuantity, timestep.TimeStep
- getCriticalTimeStep()
Returns a critical time step for an application.
- Returns:
Returns the actual (related to current state) critical time step increment
- Return type:
Physics.PhysicalQuantity
- getFieldURI(fieldID, time, objectID='')
Returns the uri of requested field at given time. Field is identified by fieldID.
- Parameters:
fieldID (DataID) – Identifier of the field
time (Physics.PhysicalQuantity) – Target time
objectID (str) – Identifies field with objectID (optional, default 0)
- Returns:
Requested field uri
- Return type:
Pyro5.api.URI
- getJobID()
- getURI()
- Returns:
Returns the application URI or None if application not registered in Pyro
- Return type:
str
- initialize(workdir='', metadata=None, validateMetaData=True, **kwargs)
Initializes application, i.e. all functions after constructor and before run.
- Parameters:
workdir (str) – Optional parameter for working directory
metadata (dict) – Optional dictionary used to set up metadata (can be also set by setMetadata() ).
validateMetaData (bool) – Defines if the metadata validation will be called
kwargs (named_arguments) – Arbitrary further parameters
- isSolved()
Check whether solve has completed.
- Returns:
Returns true or false depending whether solve has completed when executed in background.
- Return type:
bool
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'appName': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'exclusiveDaemon': FieldInfo(annotation=bool, required=False, default=False), 'metadata': FieldInfo(annotation=Union[ModelMeta, NoneType], required=False, default=None), 'pyroDaemon': FieldInfo(annotation=Union[Any, NoneType], required=False, default=None), 'pyroNS': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'pyroURI': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'workDir': FieldInfo(annotation=str, required=False, default='')}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- pyroDaemon: Any | None
- pyroNS: str | None
- pyroURI: str | None
- registerPyro(*, daemon, ns, uri, appName=None, exclusiveDaemon=False, externalDaemon=None)
Register the Pyro daemon and nameserver. Required by several services
- Parameters:
pyroDaemon (Pyro5.api.Daemon) – Optional pyro daemon
pyroNS (Pyro5.naming.Nameserver) – Optional nameserver
pyroURI (string) – Optional URI of receiver
appName (string) – Optional application name. Used for removing from pyroNS
exclusiveDaemon (bool) – Optional parameter when daemon was allocated externally.
- removeApp(nameServer=None, appName=None)
Removes (unregisters) application from the name server.
- Parameters:
nameServer (Pyro5.naming.Nameserver) – Optional instance of a nameServer
appName (str) – Optional name of the application to be removed
- restoreState(tstep)
Restore the saved state of an application. :param timestep.TimeStep tstep: Solution step
- set(obj, objectID='')
Registers the given (remote) object in application.
- Parameters:
obj (property.Property or field.Field or function.Function or pyrofile.PyroFile or heavydata.HeavyDataHandle) – Remote object to be registered by the application
objectID (str) – Identifies object with objectID (optional, default 0)
- setJobID(jobid)
- solveStep(tstep, stageID=0, runInBackground=False)
Solves the problem for given time step.
Proceeds the solution from actual state to given time. The actual state should not be updated at the end, as this method could be called multiple times for the same solution step until the global convergence is reached. When global convergence is reached, finishStep is called and then the actual state has to be updated. Solution can be split into individual stages identified by optional stageID parameter. In between the stages the additional data exchange can be performed. See also wait and isSolved services.
- Parameters:
tstep (timestep.TimeStep) – Solution step
stageID (int) – optional argument identifying solution stage (default 0)
runInBackground (bool) – optional argument, defualt False. If True, the solution will run in background (in separate thread or remotely).
- storeState(tstep)
Store the solution state of an application.
- Parameters:
tstep (timestep.TimeStep) – Solution step
- terminate()
Terminates the application. Shutdowns daemons if created internally.
- updateAndPassMetadata(dictionary: dict)
- wait()
Wait until solve is completed when executed in background.
- workDir: str
- class mupif.ModelServer(*, ns, appName, appClass, server=None, workDir=None, maxJobs=1, daemon=None, includeFiles=None)
Bases:
ModelServerBaseSimple job manager 2. This implementation avoids the problem of GIL lock by running applicaton server under new process with its own daemon.
- class ActiveJob(proc: 'typing.Union[subprocess.Popen, multiprocessing.Process]', uri: 'str', starttime: 'float', timeout: 'int', user: 'str', port: 'int', jobLogName: 'str', remoteLogUri: 'str')
Bases:
object- jobLogName: str
- port: int
- proc: Popen | Process
- remoteLogUri: str
- starttime: float
- timeout: int
- uri: str
- user: str
- class SpawnedProcessArgs(*, uriFileName: str, nsUri: str, appName: str, jobID: str, cwd: str, appClass: object)
Bases:
BaseModelArgs passed to child processes via Popen
- appClass: object
- appName: str
- cwd: str
- jobID: str
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'appClass': FieldInfo(annotation=object, required=True), 'appName': FieldInfo(annotation=str, required=True), 'cwd': FieldInfo(annotation=str, required=True), 'jobID': FieldInfo(annotation=str, required=True), 'nsUri': FieldInfo(annotation=str, required=True), 'uriFileName': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- nsUri: str
- pickle()
- classmethod unpickle(data)
- uriFileName: str
- allocateJob(user, *, remoteLogUri=None, ticket=None)
Allocates a new job.
Modified to accept optional ticket for preallocated resource. Thread safe
- Except:
unable to start a thread, no more resources
- dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
Add dunder methods based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.
- getApplicationSignature()
- getJobStatus(jobID)
Returns the status of the job.
- Parameters:
jobID (str) – jobID
- getJobWorkDir(jobID)
Returns working directory of a job with given ID.
- Parameters:
jobID (str) –
- Returns:
job working directory
- Return type:
str
- getLogFile(jobID)
- getModelMetadata()
- getNSName()
- getName()
- getNumberOfFreeJobs()
Returns number of free jobs to be allocated.
- getPyroFile(jobID, filename, mode='r', buffSize=1048576)
- getStatus() List[JobStatus]
- getStatusExtended() ModelServerStatus
- preAllocate(requirements=None)
Allows to pre-allocate(reserve) the resource. Returns ticket id (as promise) to finally allocate resource. The requirements is an optional job-man specific dictionary with additional parameters (such as number of cpus, etc). The returned ticket is valid only for fixed time period (suggest 10[s]), then should expire. Thread safe
- registerPyro(*, daemon, ns, uri, appName, exclusiveDaemon=False, externalDaemon=None)
Possibility to register the Pyro daemon and nameserver.
- Parameters:
daemon (Pyro5.api.Daemon) – Optional pyro daemon
ns (Pyro4.naming.Nameserver) – Optional nameserver
uri (string) – Optional URI of receiver
appName (string) –
exclusiveDaemon (bool) – Optional parameter when damon was allocated externally.
- runServer()
- terminate(force=False)
Terminates job manager itself.
- terminateAllJobs()
Terminates all registered jobs, frees the associated recources.
- terminateJob(jobID)
Terminates the given job, frees the associated recources.
- ticketExpireTimeout = 10
- uploadFile(jobID, filename, pyroFile)
- class mupif.ModelServerBase(*, appName, workDir=None, maxJobs=1)
Bases:
objectAn abstract (base) class representing a job manager. The purpose of the job manager is the following:
To allocate and register the new instance of application (called job)
To query the status of job
To cancel the given job
To register its interface to pyro name server
- __init__(*, appName, workDir=None, maxJobs=1)
Constructor. Initializes the receiver.
- Parameters:
appName (str) – Name of receiver (used also by NS)
workDir (str) – Absolute path for storing data, if necessary (if None, temporary directory will be created)
maxJobs (int) – Maximum number of jobs to run simultaneously
- allocateJob(user, ticket=None)
Allocates a new job.
- Parameters:
user (str) – user name
ticket – ticket for preallocated resource, defaults to None
- Returns:
tuple (error code, None). errCode = (JOBMAN_OK, JOBMAN_ERR, JOBMAN_NO_RESOURCES). JOBMAN_OK indicates sucessfull allocation and JobID contains the PYRO name, under which the new instance is registered (composed of application name and a job number (allocated by jobmanager), ie, Miccress23). JOBMAN_ERR indicates an internal error, JOBMAN_NO_RESOURCES means that job manager is not able to allocate new instance of application (no more recources available)
- Return type:
tuple
- Except:
JobManException when allocation of new job failed
- getJobStatus(jobID)
Returns the status of the job.
- Parameters:
jobID (str) – jobID
- getJobWorkDir(jobID)
Returns working directory of a job with given ID.
- Parameters:
jobID (str) –
- Returns:
job working directory
- Return type:
str
- getModelMetadata()
- getNSName()
- getName()
- getNumberOfFreeJobs()
Returns number of free jobs to be allocated.
- getPyroFile(jobID, filename, buffSize=1024)
Returns the (remote) PyroFile representation of given file. To create local copy of file represented by PyroFile, use pyroutil.downloadPyroFile, see
pyroutil.downloadPyroFile()- Parameters:
jobID (str) – job identifier (jobID)
filename (str) – source file name (on remote server). The filename should contain only base filename, not a path, which is determined by jobManager based on jobID.
buffSize (int) –
- Returns:
PyroFile representation of given file
- Return type:
- getStatus() List[JobStatus]
- preAllocate(requirements=None)
Allows to pre-allocate(reserve) the resource. Returns ticket id (as promise) to finally allocate resource. The requirements is an optional job-man specific dictionary with additional parameters (such as number of cpus, etc). The returned ticket is valid only for fixed time period), then should expire.
- registerPyro(*, daemon, ns, uri, appName, exclusiveDaemon=False, externalDaemon=None)
Possibility to register the Pyro daemon and nameserver.
- Parameters:
daemon (Pyro5.api.Daemon) – Optional pyro daemon
ns (Pyro4.naming.Nameserver) – Optional nameserver
uri (string) – Optional URI of receiver
appName (string) –
exclusiveDaemon (bool) – Optional parameter when damon was allocated externally.
- terminate()
Terminates job manager itself.
- terminateJob(jobID)
Terminates the given job, frees the associated recources.
- Parameters:
jobID (str) – jobID
- Returns:
JOBMAN_OK indicates sucessfull termination, JOBMAN_ERR means internal error
- Return type:
str
- uploadFile(jobID, filename, pyroFile)
Uploads the given file to application server, files are uploaded to dedicated jobID directory :param str jobID: jobID :param str filename: target file name :param PyroFile pyroFile: source pyroFile
- exception mupif.ModelServerException
Bases:
ExceptionThis class serves as a base class for exceptions thrown by the job manager.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mupif.ModelServerNoResourcesException
Bases:
ModelServerExceptionThis class is thrown when there are no more available resources.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mupif.MultiPiecewiseLinFunction(*, metadata={}, x: List[float] = [], x_unit: Unit = None, y: List[List[float]] = [], y_units: List[Unit] = [], y_data_ids: List[DataID] = [], y_value_types: List[ValueType] = [])
Bases:
Data- __init__(*, metadata={}, **kw)
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.
- addYData(data, unit, data_id, value_type)
- evaluate(x, data_id)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'x': FieldInfo(annotation=List[float], required=False, default=[]), 'x_unit': FieldInfo(annotation=Unit, required=False, default=None), 'y': FieldInfo(annotation=List[List[float]], required=False, default=[]), 'y_data_ids': FieldInfo(annotation=List[DataID], required=False, default=[]), 'y_units': FieldInfo(annotation=List[Unit], required=False, default=[]), 'y_value_types': FieldInfo(annotation=List[ValueType], required=False, default=[])}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- setXData(data, unit)
- x: List[float]
- y: List[List[float]]
- class mupif.MupifQuantity(value=None, unit=None, *, metadata: BaseMeta = BaseMeta(), quantity: Quantity | RefQuantity, valueType: ValueType = ValueType.Scalar)
Bases:
DataAbstract base class for representing a quantity, common parent class for
FieldandPropertyclasses. Quantity means value and an associated unit.The quantity itself can be accessed as MupifQuantity.quantity (or .q as shorthand) and can be used for unit-aware arithmetics.
Value and unit can be accessed separately as value and unit.
- dataDigest(*args)
- getQuantity()
- getValue()
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- property q
- quantity: Quantity | RefQuantity
- property unit
- property value
- mupif.NumpyArray
alias of
NDArray
- class mupif.ObjectBase
Bases:
BaseModelBasic configuration of pydantic.BaseModel, common to BareData and also WithMetadata
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.Octant_py(*, octree, parent, origin, size, level)
Bases:
objectDefines Octree Octant (Octant_py): a cell containing either terminal data or its child octants. Octree is used to partition space by recursively subdividing the root cell (square or cube) into octants. Octants can be terminal (containing the data) or can be further subdivided into children octants. Each terminal octant contains the objects with bounding box within the octant.
- __init__(*, octree, parent, origin, size, level)
The contructor. Octant_py class contains:
data: Container storing the indexed objects (cells, vertices, etc)
children: Container storing the children octants (if not terminal).
octree: Link to octree object
parent: Link to parent Octant_py
origin: Coordinates of Octant_py lower left corner
size: Dimension of Octant_py
- childrenIJK()
Returns iterator over receiver children
- Returns:
iterator over 3-tuples with child indices; functionally equivalent to 3 nested loops, a bit faster and more readable.
- containsBBox(_bbox)
- Returns:
True if BBox contains or intersects the receiver.
- divide()
Divides the receiver locally, creating child octants.
- getItemsInBBox(itemSet: set, bbox: BBox)
Returns the list of objects inside the given bounding box. Note: an object can be included several times, as can be assigned to several octants.
- Parameters:
itemSet (list) – list containing the objects matching the criteria
bbox (bbox.BBox) – target bounding box
- insert(item, bbox)
Insert given object into receiver container. Object is inserted only when its bounding box intersects the bounding box of the receiver. If the number of stored objects exceeds the limit, the receiver is adaptively refined and objects distributed to children octants.
- Parameters:
item (object) – object to insert
itemBBox (bbox.BBox) – Optional parameter determining the BBox of the object
- insertCellArrayChunk(vertices, cellData, cellOffset, mesh)
- isTerminal()
- Returns:
True if octree is the terminal cell
- class mupif.Octree(origin, size, mask)
Bases:
LocalizerAn octree is used to partition space by recursively subdividing the root cell (square or cube) into octants. Octants can be terminal (containing the data) or can be further subdivided into children octants partitioning the parent. Each terminal octant contains the objects with bounding box within the octant. Octree contains at least one octant, called root octant, with geometry large enough to contain all potential objects. Such a partitiong can significantly speed up spatial serches on objects.
Each object that can be inserted is assumed to provide getBBox() returning its bounding box.
Octree implementation supports 1D, 2D and 3D setting. This is controlled by Octree mask. Octree mask is a tuple containing 0 or 1 values. If corresponding mask value is nonzero, receiver is subdivided in corresponding coordinate direction.
- __init__(origin, size, mask)
The constructor.
- Parameters:
origin (tuple) – coordinates of lower left corner of the root octant.
size (float) – dimension (size) of the root octant
mask (tuple) – boolean tuple, where true values determine the coordinate indices in which octree octants are subdivided
- delete(item)
Deletes the given object from Localizer data structure.
- Parameters:
item (object) – Object to be removed
- evaluate(functor)
Returns the list of all objects for which the functor is satisfied.
- Parameters:
functor (object) – The functor is a class which defines two methods: giveBBox() which returns an initial functor bbox and evaluate(obj) which should return True if the functor is satisfied for a given object.
- Returns:
List of all objects
- Return type:
tuple
- getItemsInBBox(bbox: BBox)
Returns the set of objects inside the given bounding box. See
Octant.getItemsInBBox()
- insert(item, bbox)
Inserts given object into octree. See
Octant.insert()
- insertCellArrayChunk(vertices, cellData, cellOffset, mesh)
- class mupif.OperatorEMailInteraction(From, To, smtpHost, smtpUser='', smtpPsswd='', smtpSSL=False, smtpTLS=False, smtpPort=25, imapHost='', imapUser='', imapPsswd='', imapPort=993, imapSSL=True)
Bases:
OperatorInteractionDerived class implementing different communication channels.
- checkOperatorResponse(workflowID, jobID)
Check IMAP server if there is operator’s response. :param: str workflowID: unique workflow ID :param: str jobID: unique jobID :return: tuple of bool confirming existence of the message and body of the message :rtype: bool, str
- contactOperator(workflowID, jobID, msgBody)
Sends an email to the operator. :param: str workflowID: unique workflow ID :param: str jobID: unique jobID :param: str msgBody: message from operator. The message should contain an empty dictionary entry which should be filled
- class mupif.OperatorInteraction
Bases:
objectGeneric class to represent interaction with an operator. Derived classes implement different communication channels.
- checkOperatorResponse(workflowID, jobID)
Check operator response and return received data :param: str workflowID: unique workflow ID :param: str jobID: unique jobID :return: tuple (ret, Data), where ret is False if response not received, True otherwise and Data contains the operator response. :rtype: (bool, str)
- contactOperator(workflowID, jobID, msgBody)
Contact operator. :param: str workflowID: unique workflow ID :param: str jobID: unique jobID :param: str msgBody: message to operator. Recomended to store all paramaters into dictionary and convert dictionary into json string representation.
- class mupif.Particle(*, metadata: BaseMeta = BaseMeta(), set: ParticleSet, num: int)
Bases:
DataRepresentation of particle. Particle is is object characterized by its position and other attributes. Particles are typically managed by ParticleSet. Particle class is convinience mapping to ParticleSet.
- getAttribute(key)
Returns attribute identified by key @param str key: attribute key @raturn value associated with key, if not key present KeyError is raised
- getAttributes()
Returns attributes attached to particle @return dictionary of particle attributes
- getPosition()
Returns particle position
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'num': FieldInfo(annotation=int, required=True), 'set': FieldInfo(annotation=ParticleSet, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- num: int
particle index
- set: ParticleSet
master particle set
- setPosition(position)
Sets particle position @param tuple position: position vector (x,y,z)
- class mupif.ParticleSet(*, metadata: BaseMeta = BaseMeta(), id: DataID, size: int, xc: List[float] = [], yc: List[float] = [], zc: List[float] = [], rvesize: float = 0, inclusionsize: float = 0, attributes: dict = None)
Bases:
DataClass representing a collection of Particles. The set stores particle data (positions) and attributes efficiently in the form of vectors. ParticleSet keeps position vector for each particle and optional attributes (user defined) identified by key for each particle.
- attributes: dict
optional keyword arguments to define additional particle attributes, if type of values should be arrays with attribute values for each particle
- getID()
- getInclusionSize()
Returns inclusion size of particle set
- getParticle(i)
Returns representation of i-th particle in the set
- getParticleAttribute(key)
Returns array (tuple) of values corresponding to attribute identified by key
- getParticleAttributes()
Returns dictionary of set attributes
- getParticlePositions()
Returns tuple containing position vectors of particles.
- getRveSize()
Returns RVE size of particle set
- inclusionsize: float
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'attributes': FieldInfo(annotation=dict, required=False, default_factory=dict), 'id': FieldInfo(annotation=DataID, required=True), 'inclusionsize': FieldInfo(annotation=float, required=False, default=0), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'rvesize': FieldInfo(annotation=float, required=False, default=0), 'size': FieldInfo(annotation=int, required=True), 'xc': FieldInfo(annotation=List[float], required=False, default=[]), 'yc': FieldInfo(annotation=List[float], required=False, default=[]), 'zc': FieldInfo(annotation=List[float], required=False, default=[])}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- rvesize: float
- size: int
number of particles in the set
- xc: List[float]
array of particle x coordinates
- yc: List[float]
array of particle y coordinates
- zc: List[float]
array of particle z coordinates
- class mupif.PiecewiseLinFunction(*, metadata={}, dataID: DataID, valueType: ValueType, unit: Unit, inputs: dict = None, x: Quantity, y: Quantity)
Bases:
Function,DbDictable- __init__(*, metadata={}, **kw)
Initializes the function.
- Parameters:
funcID (DataID) – function ID, e.g. FuncID_ProbabilityDistribution
objectID (int) – Optional ID of associated subdomain, default 0
- dataID: dataid.DataID
- evaluate(p)
Evaluates the function for given parameters packed as a dictionary.
A dictionary is container type that can store any number of Python objects, including other container types. Dictionaries consist of pairs (called items) of keys and their corresponding values.
Example: p={‘x’:(1,2,3)*mupif.U.m, ‘t’:0.005*mupif.U.s} initializes parameter dictionary contaning vector quantity under ‘x’ key and scalar quantity under ‘t’ key.
- Parameters:
p (dictionary) – Dictionary containing function arguments (number and type depends on particular function)
- Returns:
Function value evaluated at given position and time
- Return type:
- static from_db_dict(d)
- getDataID()
Obtain function’s ID.
- Returns:
Returns receiver’s ID.
- Return type:
int
- getInputDescription()
- inputs: dict
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dataID': FieldInfo(annotation=DataID, required=True), 'inputs': FieldInfo(annotation=dict, required=False, default_factory=dict), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'unit': FieldInfo(annotation=Unit, required=True), 'valueType': FieldInfo(annotation=ValueType, required=True), 'x': FieldInfo(annotation=Quantity, required=True), 'y': FieldInfo(annotation=Quantity, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- to_db_dict(dialect: Literal['edm'] | None = None) dict[str, Any]
- to_db_dict_impl()
- unit: units.Unit
- class mupif.Process(*, metadata: BaseMeta = BaseMeta())
Bases:
BareData,WithMetadataBase class for objects which have moetadata but are not baredata (non-serializable).
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta())}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.Property(*, metadata={}, quantity: Quantity | RefQuantity, valueType: ValueType = ValueType.Scalar, propID: DataID)
Bases:
MupifQuantityProperty is a characteristic value of a problem, that does not depend on spatial variable, e.g. homogenized conductivity over the whole domain. Typically, properties are obtained by postprocessing results from lover scales by means of homogenization and are parameters of models at higher scales.
Property value can be of scalar, vector, or tensorial type. Property keeps its value, time and type.
- __init__(*, metadata={}, **kw)
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.
- dataDigest(*args)
- getDataID()
Returns DataID of property. :rtype: DataID
- getQuantity()
- getValue()
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=Union[IOMeta, NoneType], required=False, default=None), 'propID': FieldInfo(annotation=DataID, required=True), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- property q
- quantity: Union[units.Quantity, units.RefQuantity]
- property unit
- property value
- class mupif.PyroFile(*, filename: str, mode: str, bufSize: int = 1048576, compressFlag: bool = False, dataID: DataID | None = DataID.ID_None)
Bases:
UtilityHelper class wrapping file functionality, allowing copying files (both remote and local).
- bufSize: int
- close()
Closes the associated file handle.
- compressFlag: bool
- filename: str
- getBasename()
- getChunk()
Reads and returns next bufSize bytes from open (should be opened in read mode). The returned chunk may contain less bytes if not enouch data can be read, or can be empty if end-of-file is reached. :return: Returns next chunk of data read from the file :rtype: str
- getDataID()
- static makeFromUrl(url)
- mode: str
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'bufSize': FieldInfo(annotation=int, required=False, default=1048576), 'compressFlag': FieldInfo(annotation=bool, required=False, default=False), 'dataID': FieldInfo(annotation=Union[DataID, NoneType], required=False, default=<DataID.ID_None: 'ID_None'>), 'filename': FieldInfo(annotation=str, required=True), 'mode': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
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.
- Args:
self: The BaseModel instance. context: The context.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- rewind()
- setBufSize(bufSize)
Allows to set the receiver buffer size. :param int bufSize: new buffer size
- setBuffSize(bs)
- setChunk(buffer)
Writes the given chunk of data into the file, which should be opened in write mode.
- Parameters:
buffer (str) – data chunk to append
- setCompressionFlag(value=True)
Sets the compressionFlag to True
- class mupif.Quad_2d_lin(*, number: int, label: int | None = None, vertices: Tuple[int, ...], mesh: Mesh | None = None)
Bases:
CellUnstructured 2d quad element with linear interpolation
- containsPoint(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) bool
Check if a cell contains a point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if cell contains a given point
- Return type:
bool
- getBBox(relPad=1e-05)
Return bounding box. The box is by default slightly enlarged via relPad to avoid finite-precision issues when testing for a boundary point being inside the box.
- Parameters:
relPad (float) – relative padding of the box; tight (geometrical) bbox will be enlarged along each axis by relPad times size along that axis, in both directions.
- Returns:
Returns a bounding box of the receiver
- Return type:
- static getClassForCellGeometryType(cgt)
Return class object (not instance) for given cell geometry type. Does introspection of all subclasses of Cell caches the result.
- classmethod getGeometryType()
Returns geometry type of receiver.
- Returns:
Returns geometry type of receiver
- Return type:
CellGeometryType
- getMeshioGeometryStr() str
- getNumberOfVertices()
- Returns:
Number of vertices
- Return type:
int
- getTransformationJacobian(coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)])
Returns the transformation jacobian (the determinant of jacobian) of the receiver
- Parameters:
coords (tuple) – local (parametric) coordinates of the point
- Returns:
jacobian
- Return type:
float
- getVertices()
- Returns:
The list of cell vertices
- Return type:
tuple
- glob2loc(coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]]
Converts global coordinate to local (area) coordinate.
- Parameters:
coords (tuple) – A coordinate in global system
- Returns:
local (area) coordinate
- Return type:
tuple
- interpolate(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)], vertexValues: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[4, 1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Interpolates given vertex values to a given point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
vertexValues (tuple) – A tuple containing vertex values
- Returns:
Interpolated value at a given point
- Return type:
tuple
- label: Optional[int]
Cell label, arbitrary unique number.
- loc2glob(lc: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Converts local (parametric) coordinates to global ones.
- Parameters:
lc (tuple) – A local coordinate
- Returns:
global coordinate
- Return type:
tuple
- mesh: Optional['Mesh']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'mesh': FieldInfo(annotation=Union[Mesh, NoneType], required=False, default=None, exclude=True), 'number': FieldInfo(annotation=int, required=True), 'vertices': FieldInfo(annotation=Tuple[int, ...], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local cell number; local numbering should start from 0 and should be continuous.
- vertices: Tuple[int, ...]
Cell vertices (local numbers)
- class mupif.Quantity(value: astropy.units.Quantity | ~numpy._typing._array_like._Buffer | ~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]] | ~numpy._typing._nested_sequence._NestedSequence[~numpy._typing._array_like._SupportsArray[~numpy.dtype[~typing.Any]]] | complex | bytes | str | ~numpy._typing._nested_sequence._NestedSequence[complex | bytes | str], unit=None, dtype=<class 'numpy.inexact'>, copy=True, order=None, subok=False, ndmin=0)
Bases:
ndarrayA ~astropy.units.Quantity represents a number with some associated unit.
See also: https://docs.astropy.org/en/stable/units/quantity.html
7. Parameters
- valuenumber, ~numpy.ndarray, ~astropy.units.Quantity (sequence), or str
The numerical value of this quantity in the units given by unit. If a Quantity or sequence of them (or any other valid object with a
unitattribute), creates a new Quantity object, converting to unit units as needed. If a string, it is converted to a number or Quantity, depending on whether a unit is present.- unitunit-like
An object that represents the unit associated with the input value. Must be an ~astropy.units.UnitBase object or a string parseable by the
unitspackage.- dtype~numpy.dtype, optional
The dtype of the resulting Numpy array or scalar that will hold the value. If not provided, it is determined from the input, except that any integer and (non-Quantity) object inputs are converted to float by default. If None, the normal numpy.dtype introspection is used, e.g. preventing upcasting of integers.
- copybool, optional
If True (default), then the value is copied. Otherwise, a copy will only be made if
__array__returns a copy, if value is a nested sequence, or if a copy is needed to satisfy an explicitly givendtype. (The False option is intended mostly for internal use, to speed up initialization where a copy is known to have been made. Use with care.)- order{‘C’, ‘F’, ‘A’}, optional
Specify the order of the array. As in ~numpy.array. This parameter is ignored if the input is a Quantity and
copy=False.- subokbool, optional
If False (default), the returned array will be forced to be a Quantity. Otherwise, Quantity subclasses will be passed through, or a subclass appropriate for the unit will be used (such as ~astropy.units.Dex for
u.dex(u.AA)).- ndminint, optional
Specifies the minimum number of dimensions that the resulting array should have. Ones will be prepended to the shape as needed to meet this requirement. This parameter is ignored if the input is a Quantity and
copy=False.
7. Raises
- TypeError
If the value provided is not a Python numeric type.
- TypeError
If the unit provided is not either a
Unitobject or a parseable string unit.
7. Notes
Quantities can also be created by multiplying a number or array with a
Unit. See https://docs.astropy.org/en/latest/units/Unless the
dtypeargument is explicitly specified, integer or (non-Quantity) object inputs are converted to float by default.- T
View of the transposed array.
Same as
self.transpose().7. Examples
>>> import numpy as np >>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> a.T array([[1, 3], [2, 4]])
>>> a = np.array([1, 2, 3, 4]) >>> a array([1, 2, 3, 4]) >>> a.T array([1, 2, 3, 4])
7. See Also
transpose
- all(axis=None, out=None, *, keepdims=<no value>, where=<no value>)
Returns True if all elements evaluate to True.
Refer to numpy.all for full documentation.
7. See Also
numpy.all : equivalent function
- any(axis=None, out=None, *, keepdims=<no value>, where=<no value>)
Returns True if any of the elements of a evaluate to True.
Refer to numpy.any for full documentation.
7. See Also
numpy.any : equivalent function
- argmax(axis=None, out=None, *, keepdims=False)
Return indices of the maximum values along the given axis.
Refer to numpy.argmax for full documentation.
7. See Also
numpy.argmax : equivalent function
- argmin(axis=None, out=None, *, keepdims=False)
Return indices of the minimum values along the given axis.
Refer to numpy.argmin for detailed documentation.
7. See Also
numpy.argmin : equivalent function
- argpartition(kth, axis=-1, kind='introselect', order=None)
Returns the indices that would partition this array.
Refer to numpy.argpartition for full documentation.
7. See Also
numpy.argpartition : equivalent function
- argsort(axis=-1, kind=None, order=None, *, stable=None)
Returns the indices that would sort this array.
Refer to numpy.argsort for full documentation.
7. See Also
numpy.argsort : equivalent function
- astype(dtype, order='K', casting='unsafe', subok=True, copy=True)
Copy of the array, cast to a specified type.
7. Parameters
- dtypestr or dtype
Typecode or data-type to which the array is cast.
- order{‘C’, ‘F’, ‘A’, ‘K’}, optional
Controls the memory layout order of the result. ‘C’ means C order, ‘F’ means Fortran order, ‘A’ means ‘F’ order if all the arrays are Fortran contiguous, ‘C’ order otherwise, and ‘K’ means as close to the order the array elements appear in memory as possible. Default is ‘K’.
- casting{‘no’, ‘equiv’, ‘safe’, ‘same_kind’, ‘same_value’, ‘unsafe’}, optional
Controls what kind of data casting may occur. Defaults to ‘unsafe’ for backwards compatibility.
‘no’ means the data types should not be cast at all.
‘equiv’ means only byte-order changes are allowed.
‘safe’ means only casts which can preserve values are allowed.
‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.
‘unsafe’ means any data conversions may be done.
‘same_value’ means any data conversions may be done, but the values must not change, including rounding of floats or overflow of ints
New in version 2.4: Support for
'same_value'was added.- subokbool, optional
If True, then sub-classes will be passed-through (default), otherwise the returned array will be forced to be a base-class array.
- copybool, optional
By default, astype always returns a newly allocated array. If this is set to false, and the dtype, order, and subok requirements are satisfied, the input array is returned instead of a copy.
7. Returns
- arr_tndarray
Unless copy is False and the other conditions for returning the input array are satisfied (see description for copy input parameter), arr_t is a new array of the same shape as the input array, with dtype, order given by dtype, order.
7. Raises
- ComplexWarning
When casting from complex to float or int. To avoid this, one should use
a.real.astype(t).- ValueError
When casting using
'same_value'and the values change or would overflow
7. Examples
>>> import numpy as np >>> x = np.array([1, 2, 2.5]) >>> x array([1. , 2. , 2.5])
>>> x.astype(int) array([1, 2, 2])
>>> x.astype(int, casting="same_value") Traceback (most recent call last): ... ValueError: could not cast 'same_value' double to long
>>> x[:2].astype(int, casting="same_value") array([1, 2])
- base
Base object if memory is from some other object.
7. Examples
The base of an array that owns its memory is None:
>>> import numpy as np >>> x = np.array([1,2,3,4]) >>> x.base is None True
Slicing creates a view, whose memory is shared with x:
>>> y = x[2:] >>> y.base is x True
- byteswap(inplace=False)
Swap the bytes of the array elements
Toggle between low-endian and big-endian data representation by returning a byteswapped array, optionally swapped in-place. Arrays of byte-strings are not swapped. The real and imaginary parts of a complex number are swapped individually.
7. Parameters
- inplacebool, optional
If
True, swap bytes in-place, default isFalse.
7. Returns
- outndarray
The byteswapped array. If inplace is
True, this is a view to self.
7. Examples
>>> import numpy as np >>> A = np.array([1, 256, 8755], dtype=np.int16) >>> list(map(hex, A)) ['0x1', '0x100', '0x2233'] >>> A.byteswap(inplace=True) array([ 256, 1, 13090], dtype=int16) >>> list(map(hex, A)) ['0x100', '0x1', '0x3322']
Arrays of byte-strings are not swapped
>>> A = np.array([b'ceg', b'fac']) >>> A.byteswap() array([b'ceg', b'fac'], dtype='|S3')
A.view(A.dtype.newbyteorder()).byteswap()produces an array with the same values but different representation in memory>>> A = np.array([1, 2, 3],dtype=np.int64) >>> A.view(np.uint8) array([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0], dtype=uint8) >>> A.view(A.dtype.newbyteorder()).byteswap(inplace=True) array([1, 2, 3], dtype='>i8') >>> A.view(np.uint8) array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3], dtype=uint8)
- property cgs
Returns a copy of the current Quantity instance with CGS units. The value of the resulting object will be scaled.
- choose(choices, out=None, mode='raise')
Use an index array to construct a new array from a set of choices.
Refer to numpy.choose for full documentation.
7. See Also
numpy.choose : equivalent function
- clip(min=<no value>, max=<no value>, out=None, **kwargs)
Return an array whose values are limited to
[min, max]. One of max or min must be given.Refer to numpy.clip for full documentation.
7. See Also
numpy.clip : equivalent function
- compress(condition, axis=None, out=None)
Return selected slices of this array along given axis.
Refer to numpy.compress for full documentation.
7. See Also
numpy.compress : equivalent function
- conj()
Complex-conjugate all elements.
Refer to numpy.conjugate for full documentation.
7. See Also
numpy.conjugate : equivalent function
- conjugate()
Return the complex conjugate, element-wise.
Refer to numpy.conjugate for full documentation.
7. See Also
numpy.conjugate : equivalent function
- ctypes
An object to simplify the interaction of the array with the ctypes module.
This attribute creates an object that makes it easier to use arrays when calling shared libraries with the ctypes module. The returned object has, among others, data, shape, and strides attributes (see Notes below) which themselves return ctypes objects that can be used as arguments to a shared library.
7. Parameters
None
7. Returns
- cPython object
Possessing attributes data, shape, strides, etc.
7. See Also
numpy.ctypeslib
7. Notes
Below are the public attributes of this object which were documented in “Guide to NumPy” (we have omitted undocumented public attributes, as well as documented private attributes):
- _ctypes.data
A pointer to the memory area of the array as a Python integer. This memory area may contain data that is not aligned, or not in correct byte-order. The memory area may not even be writeable. The array flags and data-type of this array should be respected when passing this attribute to arbitrary C-code to avoid trouble that can include Python crashing. User Beware! The value of this attribute is exactly the same as:
self._array_interface_['data'][0].Note that unlike
data_as, a reference won’t be kept to the array: code likectypes.c_void_p((a + b).ctypes.data)will result in a pointer to a deallocated array, and should be spelt(a + b).ctypes.data_as(ctypes.c_void_p)
- _ctypes.shape
(c_intp*self.ndim): A ctypes array of length self.ndim where the basetype is the C-integer corresponding to
dtype('p')on this platform (see ~numpy.ctypeslib.c_intp). This base-type could be ctypes.c_int, ctypes.c_long, or ctypes.c_longlong depending on the platform. The ctypes array contains the shape of the underlying array.
- _ctypes.strides
(c_intp*self.ndim): A ctypes array of length self.ndim where the basetype is the same as for the shape attribute. This ctypes array contains the strides information from the underlying array. This strides information is important for showing how many bytes must be jumped to get to the next element in the array.
- _ctypes.data_as(obj)
Return the data pointer cast to a particular c-types object. For example, calling
self._as_parameter_is equivalent toself.data_as(ctypes.c_void_p). Perhaps you want to use the data as a pointer to a ctypes array of floating-point data:self.data_as(ctypes.POINTER(ctypes.c_double)).The returned pointer will keep a reference to the array.
- _ctypes.shape_as(obj)
Return the shape tuple as an array of some other c-types type. For example:
self.shape_as(ctypes.c_short).
- _ctypes.strides_as(obj)
Return the strides tuple as an array of some other c-types type. For example:
self.strides_as(ctypes.c_longlong).
If the ctypes module is not available, then the ctypes attribute of array objects still returns something useful, but ctypes objects are not returned and errors may be raised instead. In particular, the object will still have the
as_parameterattribute which will return an integer equal to the data attribute.7. Examples
>>> import numpy as np >>> import ctypes >>> x = np.array([[0, 1], [2, 3]], dtype=np.int32) >>> x array([[0, 1], [2, 3]], dtype=int32) >>> x.ctypes.data 31962608 # may vary >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32)) <__main__.LP_c_uint object at 0x7ff2fc1fc200> # may vary >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint32)).contents c_uint(0) >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_uint64)).contents c_ulong(4294967296) >>> x.ctypes.shape <numpy._core._internal.c_long_Array_2 object at 0x7ff2fc1fce60> # may vary >>> x.ctypes.strides <numpy._core._internal.c_long_Array_2 object at 0x7ff2fc1ff320> # may vary
- cumprod(axis=None, dtype=None, out=None)
Return the cumulative product of the elements along the given axis.
Refer to numpy.cumprod for full documentation.
7. See Also
numpy.cumprod : equivalent function
- cumsum(axis=None, dtype=None, out=None)
Return the cumulative sum of the elements along the given axis.
Refer to numpy.cumsum for full documentation.
7. See Also
numpy.cumsum : equivalent function
- data
Python buffer object pointing to the start of the array’s data.
- decompose(bases: Collection[UnitBase] = ()) Self
Generates a new Quantity with the units decomposed. Decomposed units have only irreducible units in them (see astropy.units.UnitBase.decompose).
7. Parameters
- basessequence of ~astropy.units.UnitBase, optional
The bases to decompose into. When not provided, decomposes down to any irreducible units. When provided, the decomposed result will only contain the given units. This will raises a ~astropy.units.UnitsError if it’s not possible to do so.
7. Returns
- newq~astropy.units.Quantity
A new object equal to this quantity with units decomposed.
- device
- diagonal(offset=0, axis1=0, axis2=1)
Return specified diagonals. In NumPy 1.9 the returned array is a read-only view instead of a copy as in previous NumPy versions. In a future version the read-only restriction will be removed.
Refer to
numpy.diagonal()for full documentation.7. See Also
numpy.diagonal : equivalent function
- diff(n=1, axis=-1)
- dot(other, /, out=None)
Refer to
numpy.dot()for full documentation.7. See Also
numpy.dot : equivalent function
- dtype
Data-type of the array’s elements.
Warning
Setting
arr.dtypeis discouraged and may be deprecated in the future. Setting will replace thedtypewithout modifying the memory (see also ndarray.view and ndarray.astype).7. Parameters
None
7. Returns
d : numpy dtype object
7. See Also
ndarray.astype : Cast the values contained in the array to a new data-type. ndarray.view : Create a view of the same data but a different data-type. numpy.dtype
7. Examples
>>> import numpy as np >>> x = np.arange(4).reshape((2, 2)) >>> x array([[0, 1], [2, 3]]) >>> x.dtype dtype('int64') # may vary (OS, bitness) >>> isinstance(x.dtype, np.dtype) True
- dump(file)
Not implemented, use
.value.dump()instead.
- dumps()
Not implemented, use
.value.dumps()instead.
- ediff1d(to_end=None, to_begin=None)
- property equivalencies
A list of equivalencies that will be applied by default during unit conversions.
- fill(value)
Fill the array with a scalar value.
7. Parameters
- valuescalar
All elements of a will be assigned this value.
7. Examples
>>> import numpy as np >>> a = np.array([1, 2]) >>> a.fill(0) >>> a array([0, 0]) >>> a = np.empty(2) >>> a.fill(1) >>> a array([1., 1.])
Fill expects a scalar value and always behaves the same as assigning to a single array element. The following is a rare example where this distinction is important:
>>> a = np.array([None, None], dtype=object) >>> a[0] = np.array(3) >>> a array([array(3), None], dtype=object) >>> a.fill(np.array(3)) >>> a array([array(3), array(3)], dtype=object)
Where other forms of assignments will unpack the array being assigned:
>>> a[...] = np.array(3) >>> a array([3, 3], dtype=object)
- flags
Information about the memory layout of the array.
7. Attributes
- C_CONTIGUOUS (C)
The data is in a single, C-style contiguous segment.
- F_CONTIGUOUS (F)
The data is in a single, Fortran-style contiguous segment.
- OWNDATA (O)
The array owns the memory it uses or borrows it from another object.
- WRITEABLE (W)
The data area can be written to. Setting this to False locks the data, making it read-only. A view (slice, etc.) inherits WRITEABLE from its base array at creation time, but a view of a writeable array may be subsequently locked while the base array remains writeable. (The opposite is not true, in that a view of a locked array may not be made writeable. However, currently, locking a base object does not lock any views that already reference it, so under that circumstance it is possible to alter the contents of a locked array via a previously created writeable view onto it.) Attempting to change a non-writeable array raises a RuntimeError exception.
- ALIGNED (A)
The data and all elements are aligned appropriately for the hardware.
- WRITEBACKIFCOPY (X)
This array is a copy of some other array. The C-API function PyArray_ResolveWritebackIfCopy must be called before deallocating to the base array will be updated with the contents of this array.
- FNC
F_CONTIGUOUS and not C_CONTIGUOUS.
- FORC
F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).
- BEHAVED (B)
ALIGNED and WRITEABLE.
- CARRAY (CA)
BEHAVED and C_CONTIGUOUS.
- FARRAY (FA)
BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.
7. Notes
The flags object can be accessed dictionary-like (as in
a.flags['WRITEABLE']), or by using lowercased attribute names (as ina.flags.writeable). Short flag names are only supported in dictionary access.Only the WRITEBACKIFCOPY, WRITEABLE, and ALIGNED flags can be changed by the user, via direct assignment to the attribute or dictionary entry, or by calling ndarray.setflags.
The array flags cannot be set arbitrarily:
WRITEBACKIFCOPY can only be set
False.ALIGNED can only be set
Trueif the data is truly aligned.WRITEABLE can only be set
Trueif the array owns its own memory or the ultimate owner of the memory exposes a writeable buffer interface or is a string.
Arrays can be both C-style and Fortran-style contiguous simultaneously. This is clear for 1-dimensional arrays, but can also be true for higher dimensional arrays.
Even for contiguous arrays a stride for a given dimension
arr.strides[dim]may be arbitrary ifarr.shape[dim] == 1or the array has no elements. It does not generally hold thatself.strides[-1] == self.itemsizefor C-style contiguous arrays orself.strides[0] == self.itemsizefor Fortran-style contiguous arrays is true.
- property flat
A 1-D iterator over the Quantity array.
This returns a
QuantityIteratorinstance, which behaves the same as the ~numpy.flatiter instance returned by ~numpy.ndarray.flat, and is similar to, but not a subclass of, Python’s built-in iterator object.
- flatten(order='C')
Return a copy of the array collapsed into one dimension.
7. Parameters
- order{‘C’, ‘F’, ‘A’, ‘K’}, optional
‘C’ means to flatten in row-major (C-style) order. ‘F’ means to flatten in column-major (Fortran- style) order. ‘A’ means to flatten in column-major order if a is Fortran contiguous in memory, row-major order otherwise. ‘K’ means to flatten a in the order the elements occur in memory. The default is ‘C’.
7. Returns
- yndarray
A copy of the input array, flattened to one dimension.
7. See Also
ravel : Return a flattened array. flat : A 1-D flat iterator over the array.
7. Examples
>>> import numpy as np >>> a = np.array([[1,2], [3,4]]) >>> a.flatten() array([1, 2, 3, 4]) >>> a.flatten('F') array([1, 3, 2, 4])
- getUnitName()
- getValue()
- getfield(dtype, offset=0)
Returns a field of the given array as a certain type.
A field is a view of the array data with a given data-type. The values in the view are determined by the given type and the offset into the current array in bytes. The offset needs to be such that the view dtype fits in the array dtype; for example an array of dtype complex128 has 16-byte elements. If taking a view with a 32-bit integer (4 bytes), the offset needs to be between 0 and 12 bytes.
7. Parameters
- dtypestr or dtype
The data type of the view. The dtype size of the view can not be larger than that of the array itself.
- offsetint
Number of bytes to skip before beginning the element view.
7. Examples
>>> import numpy as np >>> x = np.diag([1.+1.j]*2) >>> x[1, 1] = 2 + 4.j >>> x array([[1.+1.j, 0.+0.j], [0.+0.j, 2.+4.j]]) >>> x.getfield(np.float64) array([[1., 0.], [0., 2.]])
By choosing an offset of 8 bytes we can select the complex part of the array for our view:
>>> x.getfield(np.float64, offset=8) array([[1., 0.], [0., 4.]])
- imag
The imaginary part of the array.
7. Examples
>>> import numpy as np >>> x = np.sqrt([1+0j, 0+1j]) >>> x.imag array([ 0. , 0.70710678]) >>> x.imag.dtype dtype('float64')
- inBaseUnits()
- inUnitsOf(unit, equivalencies=[], copy=True)
Return a new ~astropy.units.Quantity object with the specified unit.
7. Parameters
- unitunit-like
An object that represents the unit to convert to. Must be an ~astropy.units.UnitBase object or a string parseable by the ~astropy.units package.
- equivalencieslist of tuple
A list of equivalence pairs to try if the units are not directly convertible. See Equivalencies. If not provided or
[], class default equivalencies will be used (none for ~astropy.units.Quantity, but may be set for subclasses) If None, no equivalencies will be applied at all, not even any set globally or within a context.- copybool, optional
If True (default), then the value is copied. Otherwise, a copy will only be made if necessary.
7. See Also
to_value : get the numerical value in a given unit.
- info
Container for meta information like name, description, format. This is required when the object is used as a mixin column within a table, but can be used as a general way to store meta information.
- insert(obj, values, axis=None)
Insert values along the given axis before the given indices and return a new ~astropy.units.Quantity object.
This is a thin wrapper around the numpy.insert function.
7. Parameters
- objint, slice or sequence of int
Object that defines the index or indices before which
valuesis inserted.- valuesarray-like
Values to insert. If the type of
valuesis different from that of quantity,valuesis converted to the matching type.valuesshould be shaped so that it can be broadcast appropriately The unit ofvaluesmust be consistent with this quantity.- axisint, optional
Axis along which to insert
values. Ifaxisis None then the quantity array is flattened before insertion.
7. Returns
- out~astropy.units.Quantity
A copy of quantity with
valuesinserted. Note that the insertion does not occur in-place: a new quantity array is returned.
7. Examples
>>> import astropy.units as u >>> q = [1, 2] * u.m >>> q.insert(0, 50 * u.cm) <Quantity [ 0.5, 1., 2.] m>
>>> q = [[1, 2], [3, 4]] * u.m >>> q.insert(1, [10, 20] * u.m, axis=0) <Quantity [[ 1., 2.], [ 10., 20.], [ 3., 4.]] m>
>>> q.insert(1, 10 * u.m, axis=1) <Quantity [[ 1., 10., 2.], [ 3., 10., 4.]] m>
- isCompatible(u2)
- property isscalar
True if the value of this quantity is a scalar, or False if it is an array-like object.
Note
This is subtly different from numpy.isscalar in that numpy.isscalar returns False for a zero-dimensional array (e.g.
np.array(1)), while this is True for quantities, since quantities cannot represent true numpy scalars.
- item(*args)
Copy an element of an array to a scalar Quantity and return it.
Like
item()except that it always returns a Quantity, not a Python scalar.
- itemsize
Length of one array element in bytes.
7. Examples
>>> import numpy as np >>> x = np.array([1,2,3], dtype=np.float64) >>> x.itemsize 8 >>> x = np.array([1,2,3], dtype=np.complex128) >>> x.itemsize 16
- mT
View of the matrix transposed array.
The matrix transpose is the transpose of the last two dimensions, even if the array is of higher dimension.
New in version 2.0.
7. Raises
- ValueError
If the array is of dimension less than 2.
7. Examples
>>> import numpy as np >>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> a.mT array([[1, 3], [2, 4]])
>>> a = np.arange(8).reshape((2, 2, 2)) >>> a array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]]) >>> a.mT array([[[0, 2], [1, 3]], [[4, 6], [5, 7]]])
- max(axis=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)
Return the maximum along a given axis.
Refer to numpy.amax for full documentation.
7. See Also
numpy.amax : equivalent function
- mean(axis=None, dtype=None, out=None, *, keepdims=<no value>, where=<no value>)
Returns the average of the array elements along given axis.
Refer to numpy.mean for full documentation.
7. See Also
numpy.mean : equivalent function
- min(axis=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)
Return the minimum along a given axis.
Refer to numpy.amin for full documentation.
7. See Also
numpy.amin : equivalent function
- nbytes
Total bytes consumed by the elements of the array.
7. Notes
Does not include memory consumed by non-element attributes of the array object.
7. See Also
- sys.getsizeof
Memory consumed by the object itself without parents in case view. This does include memory consumed by non-element attributes.
7. Examples
>>> import numpy as np >>> x = np.zeros((3,5,2), dtype=np.complex128) >>> x.nbytes 480 >>> np.prod(x.shape) * x.itemsize 480
- ndim
Number of array dimensions.
7. Examples
>>> import numpy as np >>> x = np.array([1, 2, 3]) >>> x.ndim 1 >>> y = np.zeros((2, 3, 4)) >>> y.ndim 3
- nonzero()
Return the indices of the elements that are non-zero.
Refer to numpy.nonzero for full documentation.
7. See Also
numpy.nonzero : equivalent function
- partition(kth, axis=-1, kind='introselect', order=None)
Partially sorts the elements in the array in such a way that the value of the element in k-th position is in the position it would be in a sorted array. In the output array, all elements smaller than the k-th element are located to the left of this element and all equal or greater are located to its right. The ordering of the elements in the two partitions on the either side of the k-th element in the output array is undefined.
7. Parameters
- kthint or sequence of ints
Element index to partition by. The kth element value will be in its final sorted position and all smaller elements will be moved before it and all equal or greater elements behind it. The order of all elements in the partitions is undefined. If provided with a sequence of kth it will partition all elements indexed by kth of them into their sorted position at once.
Deprecated since version 1.22.0: Passing booleans as index is deprecated.
- axisint, optional
Axis along which to sort. Default is -1, which means sort along the last axis.
- kind{‘introselect’}, optional
Selection algorithm. Default is ‘introselect’.
- orderstr or list of str, optional
When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need to be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties.
7. See Also
numpy.partition : Return a partitioned copy of an array. argpartition : Indirect partition. sort : Full sort.
7. Notes
See
np.partitionfor notes on the different algorithms.7. Examples
>>> import numpy as np >>> a = np.array([3, 4, 2, 1]) >>> a.partition(3) >>> a array([2, 1, 3, 4]) # may vary
>>> a.partition((1, 3)) >>> a array([1, 2, 3, 4])
- prod(axis=None, dtype=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)
Return the product of the array elements over the given axis
Refer to numpy.prod for full documentation.
7. See Also
numpy.prod : equivalent function
- put(indices, values, mode='raise')
Set
a.flat[n] = values[n]for allnin indices.Refer to numpy.put for full documentation.
7. See Also
numpy.put : equivalent function
- ravel(order='C')
Return a flattened array.
Refer to numpy.ravel for full documentation.
7. See Also
numpy.ravel : equivalent function ndarray.flat : a flat iterator on the array.
- real
The real part of the array.
7. Examples
>>> import numpy as np >>> x = np.sqrt([1+0j, 0+1j]) >>> x.real array([ 1. , 0.70710678]) >>> x.real.dtype dtype('float64')
7. See Also
numpy.real : equivalent function
- repeat(repeats, axis=None)
Repeat elements of an array.
Refer to numpy.repeat for full documentation.
7. See Also
numpy.repeat : equivalent function
- reshape(shape, /, *, order='C', copy=None)
- reshape(*shape, order='C', copy=None) None
Returns an array containing the same data with a new shape.
Refer to numpy.reshape for full documentation.
7. See Also
numpy.reshape : equivalent function
7. Notes
Unlike the free function numpy.reshape, this method on ndarray allows the elements of the shape parameter to be passed in as separate arguments. For example,
a.reshape(4, 2)is equivalent toa.reshape((4, 2)).
- resize(new_shape, /, *, refcheck=True)
- resize(*new_shape, refcheck=True) None
Change shape and size of array in-place.
7. Parameters
- new_shapetuple of ints, or n ints
Shape of resized array.
- refcheckbool, optional
If False, reference count will not be checked. Default is True. See Notes below for more explanation.
7. Returns
None
7. Raises
- ValueError
If a does not own its own data or references or views to may exist.
7. See Also
resize : Return a new array with the specified shape.
7. Notes
This reallocates space for the data area if necessary.
Only contiguous arrays (data elements consecutive in memory) can be resized.
Reallocating arrays in-place can often lead to memory fragmentation and should be avoided. If the goal is to reclaim over-allocated memory, alternatives are to create a view or a copy of just the desired data, or using two passes to build the array: one to cheaply determine the shape and another to allocate and fill. Benchmark your use case to determine what is optimum. You may be surprised to find
resizeactually slows down or bloats your application.The purpose of the reference count check is to make sure you do not use this array as a buffer for another Python object and then reallocate the memory.
On Python 3.13 and older, the check allows objects with exactly one reference to be reallocated in-place. On Python 3.14 and newer, the array must be uniquely referenced. See [1] for more details.
If you are sure that you have not shared the memory for this array with another Python object, then you may safely set refcheck to False.
7. References
7. Examples
Shrinking an array: array is flattened (in the order that the data are stored in memory), resized, and reshaped:
>>> import numpy as np
>>> a = np.array([[0, 1], [2, 3]], order='C') >>> a.resize((2, 1)) >>> a array([[0], [1]])
>>> a = np.array([[0, 1], [2, 3]], order='F') >>> a.resize((2, 1)) >>> a array([[0], [2]])
Enlarging an array: as above, but missing entries are filled with zeros:
>>> b = np.array([[0, 1], [2, 3]]) >>> b.resize(2, 3) # new_shape parameter doesn't have to be a tuple >>> b array([[0, 1, 2], [3, 0, 0]])
Referencing an array prevents resizing…
>>> c = a >>> a.resize((1, 1)) Traceback (most recent call last): ... ValueError: cannot resize an array that references or is referenced ...
Unless refcheck is False:
>>> a.resize((1, 1), refcheck=False) >>> a array([[0]]) >>> c array([[0]])
- round(decimals=0, out=None)
Return a with each element rounded to the given number of decimals.
Refer to numpy.around for full documentation.
7. See Also
numpy.around : equivalent function
- searchsorted(v, side='left', sorter=None)
Find indices where elements of v should be inserted in a to maintain order.
For full documentation, see numpy.searchsorted.
7. See Also
numpy.searchsorted : equivalent function
- setfield(val, dtype, offset=0)
Put a value into a specified place in a field defined by a data-type.
Place val into a’s field defined by dtype and beginning offset bytes into the field.
7. Parameters
- valobject
Value to be placed in field.
- dtypedtype object
Data-type of the field in which to place val.
- offsetint, optional
The number of bytes into the field at which to place val.
7. Returns
None
7. See Also
getfield
7. Examples
>>> import numpy as np >>> x = np.eye(3) >>> x.getfield(np.float64) array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) >>> x.setfield(3, np.int32) >>> x.getfield(np.int32) array([[3, 3, 3], [3, 3, 3], [3, 3, 3]], dtype=int32) >>> x array([[1.0e+000, 1.5e-323, 1.5e-323], [1.5e-323, 1.0e+000, 1.5e-323], [1.5e-323, 1.5e-323, 1.0e+000]]) >>> x.setfield(np.eye(3), np.int32) >>> x array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
- setflags(write=None, align=None, uic=None)
Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively.
These Boolean-valued flags affect how numpy interprets the memory area used by a (see Notes below). The ALIGNED flag can only be set to True if the data is actually aligned according to the type. The WRITEBACKIFCOPY flag can never be set to True. The flag WRITEABLE can only be set to True if the array owns its own memory, or the ultimate owner of the memory exposes a writeable buffer interface, or is a string. (The exception for string is made so that unpickling can be done without copying memory.)
7. Parameters
- writebool, optional
Describes whether or not a can be written to.
- alignbool, optional
Describes whether or not a is aligned properly for its type.
- uicbool, optional
Describes whether or not a is a copy of another “base” array.
7. Notes
Array flags provide information about how the memory area used for the array is to be interpreted. There are 7 Boolean flags in use, only three of which can be changed by the user: WRITEBACKIFCOPY, WRITEABLE, and ALIGNED.
WRITEABLE (W) the data area can be written to;
ALIGNED (A) the data and strides are aligned appropriately for the hardware (as determined by the compiler);
WRITEBACKIFCOPY (X) this array is a copy of some other array (referenced by .base). When the C-API function PyArray_ResolveWritebackIfCopy is called, the base array will be updated with the contents of this array.
All flags can be accessed using the single (upper case) letter as well as the full name.
7. Examples
>>> import numpy as np >>> y = np.array([[3, 1, 7], ... [2, 0, 0], ... [8, 5, 9]]) >>> y array([[3, 1, 7], [2, 0, 0], [8, 5, 9]]) >>> y.flags C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : True ALIGNED : True WRITEBACKIFCOPY : False >>> y.setflags(write=0, align=0) >>> y.flags C_CONTIGUOUS : True F_CONTIGUOUS : False OWNDATA : True WRITEABLE : False ALIGNED : False WRITEBACKIFCOPY : False >>> y.setflags(uic=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: cannot set WRITEBACKIFCOPY flag to True
- shape
Tuple of array dimensions.
The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of the array and the remaining dimensions. Reshaping an array in-place will fail if a copy is required.
Warning
Setting
arr.shapeis discouraged and may be deprecated in the future. Using ndarray.reshape is the preferred approach.7. Examples
>>> import numpy as np >>> x = np.array([1, 2, 3, 4]) >>> x.shape (4,) >>> y = np.zeros((2, 3, 4)) >>> y.shape (2, 3, 4) >>> y.shape = (3, 8) >>> y array([[ 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0.]]) >>> y.shape = (3, 6) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: cannot reshape array of size 24 into shape (3,6) >>> np.zeros((4,2))[::2].shape = (-1,) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: Incompatible shape for in-place modification. Use `.reshape()` to make a copy with the desired shape.
7. See Also
numpy.shape : Equivalent getter function. numpy.reshape : Function similar to setting
shape. ndarray.reshape : Method similar to settingshape.
- property si
Returns a copy of the current Quantity instance with SI units. The value of the resulting object will be scaled.
- size
Number of elements in the array.
Equal to
np.prod(a.shape), i.e., the product of the array’s dimensions.7. Notes
a.size returns a standard arbitrary precision Python integer. This may not be the case with other methods of obtaining the same value (like the suggested
np.prod(a.shape), which returns an instance ofnp.int_), and may be relevant if the value is used further in calculations that may overflow a fixed size integer type.7. Examples
>>> import numpy as np >>> x = np.zeros((3, 5, 2), dtype=np.complex128) >>> x.size 30 >>> np.prod(x.shape) 30
- sort(axis=-1, kind=None, order=None, *, stable=None)
Sort an array in-place. Refer to numpy.sort for full documentation.
7. Parameters
- axisint, optional
Axis along which to sort. Default is -1, which means sort along the last axis.
- kind{‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’}, optional
Sorting algorithm. The default is ‘quicksort’. Note that both ‘stable’ and ‘mergesort’ use timsort under the covers and, in general, the actual implementation will vary with datatype. The ‘mergesort’ option is retained for backwards compatibility.
- orderstr or list of str, optional
When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. A single field can be specified as a string, and not all fields need be specified, but unspecified fields will still be used, in the order in which they come up in the dtype, to break ties.
- stablebool, optional
Sort stability. If
True, the returned array will maintain the relative order ofavalues which compare as equal. IfFalseorNone, this is not guaranteed. Internally, this option selectskind='stable'. Default:None.New in version 2.0.0.
7. See Also
numpy.sort : Return a sorted copy of an array. numpy.argsort : Indirect sort. numpy.lexsort : Indirect stable sort on multiple keys. numpy.searchsorted : Find elements in sorted array. numpy.partition: Partial sort.
7. Notes
See numpy.sort for notes on the different sorting algorithms.
7. Examples
>>> import numpy as np >>> a = np.array([[1,4], [3,1]]) >>> a.sort(axis=1) >>> a array([[1, 4], [1, 3]]) >>> a.sort(axis=0) >>> a array([[1, 3], [1, 4]])
Use the order keyword to specify a field to use when sorting a structured array:
>>> a = np.array([('a', 2), ('c', 1)], dtype=[('x', 'S1'), ('y', int)]) >>> a.sort(order='y') >>> a array([(b'c', 1), (b'a', 2)], dtype=[('x', 'S1'), ('y', '<i8')])
- squeeze(axis=None)
Remove axes of length one from a.
Refer to numpy.squeeze for full documentation.
7. See Also
numpy.squeeze : equivalent function
- std(axis=None, dtype=None, out=None, ddof=0, *, keepdims=<no value>, where=<no value>, mean=<no value>)
Returns the standard deviation of the array elements along given axis.
Refer to numpy.std for full documentation.
7. See Also
numpy.std : equivalent function
- strides
Tuple of bytes to step in each dimension when traversing an array.
The byte offset of element
(i[0], i[1], ..., i[n])in an array a is:offset = sum(np.array(i) * a.strides)
A more detailed explanation of strides can be found in arrays.ndarray.
Warning
Setting
arr.stridesis discouraged and may be deprecated in the future. numpy.lib.stride_tricks.as_strided should be preferred to create a new view of the same data in a safer way.7. Notes
Imagine an array of 32-bit integers (each 4 bytes):
x = np.array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]], dtype=np.int32)
This array is stored in memory as 40 bytes, one after the other (known as a contiguous block of memory). The strides of an array tell us how many bytes we have to skip in memory to move to the next position along a certain axis. For example, we have to skip 4 bytes (1 value) to move to the next column, but 20 bytes (5 values) to get to the same position in the next row. As such, the strides for the array x will be
(20, 4).7. See Also
numpy.lib.stride_tricks.as_strided
7. Examples
>>> import numpy as np >>> y = np.reshape(np.arange(2 * 3 * 4, dtype=np.int32), (2, 3, 4)) >>> y array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]]], dtype=np.int32) >>> y.strides (48, 16, 4) >>> y[1, 1, 1] np.int32(17) >>> offset = sum(y.strides * np.array((1, 1, 1))) >>> offset // y.itemsize np.int64(17)
>>> x = np.reshape(np.arange(5*6*7*8, dtype=np.int32), (5, 6, 7, 8)) >>> x = x.transpose(2, 3, 1, 0) >>> x.strides (32, 4, 224, 1344) >>> i = np.array([3, 5, 2, 2], dtype=np.int32) >>> offset = sum(i * x.strides) >>> x[3, 5, 2, 2] np.int32(813) >>> offset // x.itemsize np.int64(813)
- sum(axis=None, dtype=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)
Return the sum of the array elements over the given axis.
Refer to numpy.sum for full documentation.
7. See Also
numpy.sum : equivalent function
- swapaxes(axis1, axis2, /)
Return a view of the array with axis1 and axis2 interchanged.
Refer to numpy.swapaxes for full documentation.
7. See Also
numpy.swapaxes : equivalent function
- take(indices, axis=None, out=None, mode='raise')
Return an array formed from the elements of a at the given indices.
Refer to numpy.take for full documentation.
7. See Also
numpy.take : equivalent function
- to(unit, equivalencies=[], copy=True)
Return a new ~astropy.units.Quantity object with the specified unit.
7. Parameters
- unitunit-like
An object that represents the unit to convert to. Must be an ~astropy.units.UnitBase object or a string parseable by the ~astropy.units package.
- equivalencieslist of tuple
A list of equivalence pairs to try if the units are not directly convertible. See Equivalencies. If not provided or
[], class default equivalencies will be used (none for ~astropy.units.Quantity, but may be set for subclasses) If None, no equivalencies will be applied at all, not even any set globally or within a context.- copybool, optional
If True (default), then the value is copied. Otherwise, a copy will only be made if necessary.
7. See Also
to_value : get the numerical value in a given unit.
- to_device(device, /, *, stream=None)
For Array API compatibility. Since NumPy only supports CPU arrays, this method is a no-op that returns the same array.
7. Parameters
- device“cpu”
Must be
"cpu".- streamNone, optional
Currently unsupported.
7. Returns
- outSelf
Returns the same array.
- to_string(unit=None, precision=None, format=None, subfmt=None, *, formatter=None)
Generate a string representation of the quantity and its unit.
The behavior of this function can be altered via the numpy.set_printoptions function and its various keywords. The exception to this is the
thresholdkeyword, which is controlled via the[units.quantity]configuration itemlatex_array_threshold. This is treated separately because the numpy default of 1000 is too big for most browsers to handle.7. Parameters
- unitunit-like, optional
Specifies the unit. If not provided, the unit used to initialize the quantity will be used.
- precisionnumber, optional
The level of decimal precision. If None, or not provided, it will be determined from NumPy print options.
- formatstr, optional
The format of the result. If not provided, an unadorned string is returned. Supported values are:
‘latex’: Return a LaTeX-formatted string
‘latex_inline’: Return a LaTeX-formatted string that uses negative exponents instead of fractions
- formatterstr, callable, dict, optional
The formatter to use for the value. If a string, it should be a valid format specifier using Python’s mini-language. If a callable, it will be treated as the default formatter for all values and will overwrite default Latex formatting for exponential notation and complex numbers. If a dict, it should map a specific type to a callable to be directly passed into numpy.array2string. If not provided, the default formatter will be used.
- subfmtstr, optional
Subformat of the result. For the moment, only used for
format='latex'andformat='latex_inline'. Supported values are:‘inline’: Use
$ ... $as delimiters.‘display’: Use
$\displaystyle ... $as delimiters.
7. Returns
- str
A string with the contents of this Quantity
- to_value(unit=None, equivalencies=[])
The numerical value, possibly in a different unit.
7. Parameters
- unitunit-like, optional
The unit in which the value should be given. If not given or None, use the current unit.
- equivalencieslist of tuple, optional
A list of equivalence pairs to try if the units are not directly convertible (see Equivalencies). If not provided or
[], class default equivalencies will be used (none for ~astropy.units.Quantity, but may be set for subclasses). If None, no equivalencies will be applied at all, not even any set globally or within a context.
7. Returns
- valuendarray or scalar
The value in the units specified. For arrays, this will be a view of the data if no unit conversion was necessary.
7. See Also
to : Get a new instance in a different unit.
- tobytes(order='C')
Not implemented, use
.value.tobytes()instead.
- tofile(fid, sep='', format='%s')
Not implemented, use
.value.tofile()instead.
- tolist()
Return the array as an
a.ndim-levels deep nested list of Python scalars.Return a copy of the array data as a (nested) Python list. Data items are converted to the nearest compatible builtin Python type, via the ~numpy.ndarray.item method.
If
a.ndimis 0, then since the depth of the nested list is 0, it will not be a list at all, but a simple Python scalar.7. Parameters
none
7. Returns
- yobject, or list of object, or list of list of object, or …
The possibly nested list of array elements.
7. Notes
The array may be recreated via
a = np.array(a.tolist()), although this may sometimes lose precision.7. Examples
For a 1D array,
a.tolist()is almost the same aslist(a), except thattolistchanges numpy scalars to Python scalars:>>> import numpy as np >>> a = np.uint32([1, 2]) >>> a_list = list(a) >>> a_list [np.uint32(1), np.uint32(2)] >>> type(a_list[0]) <class 'numpy.uint32'> >>> a_tolist = a.tolist() >>> a_tolist [1, 2] >>> type(a_tolist[0]) <class 'int'>
Additionally, for a 2D array,
tolistapplies recursively:>>> a = np.array([[1, 2], [3, 4]]) >>> list(a) [array([1, 2]), array([3, 4])] >>> a.tolist() [[1, 2], [3, 4]]
The base case for this recursion is a 0D array:
>>> a = np.array(1) >>> list(a) Traceback (most recent call last): ... TypeError: iteration over a 0-d array >>> a.tolist() 1
- tostring(order='C')
Not implemented, use
.value.tostring()instead.
- trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
Return the sum along diagonals of the array.
Refer to numpy.trace for full documentation.
7. See Also
numpy.trace : equivalent function
- transpose(*axes)
Returns a view of the array with axes transposed.
Refer to numpy.transpose for full documentation.
7. Parameters
axes : None, tuple of ints, or n ints
None or no argument: reverses the order of the axes.
tuple of ints: i in the j-th place in the tuple means that the array’s i-th axis becomes the transposed array’s j-th axis.
n ints: same as an n-tuple of the same ints (this form is intended simply as a “convenience” alternative to the tuple form).
7. Returns
- pndarray
View of the array with its axes suitably permuted.
7. See Also
transpose : Equivalent function. ndarray.T : Array property returning the array transposed. ndarray.reshape : Give a new shape to an array without changing its data.
7. Examples
>>> import numpy as np >>> a = np.array([[1, 2], [3, 4]]) >>> a array([[1, 2], [3, 4]]) >>> a.transpose() array([[1, 3], [2, 4]]) >>> a.transpose((1, 0)) array([[1, 3], [2, 4]]) >>> a.transpose(1, 0) array([[1, 3], [2, 4]])
>>> a = np.array([1, 2, 3, 4]) >>> a array([1, 2, 3, 4]) >>> a.transpose() array([1, 2, 3, 4])
- property unit
A ~astropy.units.UnitBase object representing the unit of this quantity.
- property value
The numerical value of this instance.
7. See also
to_value : Get the numerical value in a given unit.
- var(axis=None, dtype=None, out=None, ddof=0, *, keepdims=<no value>, where=<no value>, mean=<no value>)
Returns the variance of the array elements, along given axis.
Refer to numpy.var for full documentation.
7. See Also
numpy.var : equivalent function
- view([dtype][, type])
New view of array with the same data.
Note
Passing None for
dtypeis different from omitting the parameter, since the former invokesdtype(None)which is an alias fordtype('float64').7. Parameters
- dtypedata-type or ndarray sub-class, optional
Data-type descriptor of the returned view, e.g., float32 or int16. Omitting it results in the view having the same data-type as a. This argument can also be specified as an ndarray sub-class, which then specifies the type of the returned object (this is equivalent to setting the
typeparameter).- typePython type, optional
Type of the returned view, e.g., ndarray or matrix. Again, omission of the parameter results in type preservation.
7. Notes
a.view()is used two different ways:a.view(some_dtype)ora.view(dtype=some_dtype)constructs a view of the array’s memory with a different data-type. This can cause a reinterpretation of the bytes of memory.a.view(ndarray_subclass)ora.view(type=ndarray_subclass)just returns an instance of ndarray_subclass that looks at the same array (same shape, dtype, etc.) This does not cause a reinterpretation of the memory.For
a.view(some_dtype), ifsome_dtypehas a different number of bytes per entry than the previous dtype (for example, converting a regular array to a structured array), then the last axis ofamust be contiguous. This axis will be resized in the result.Changed in version 1.23.0: Only the last axis needs to be contiguous. Previously, the entire array had to be C-contiguous.
7. Examples
>>> import numpy as np >>> x = np.array([(-1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
Viewing array data using a different type and dtype:
>>> nonneg = np.dtype([("a", np.uint8), ("b", np.uint8)]) >>> y = x.view(dtype=nonneg, type=np.recarray) >>> x["a"] array([-1], dtype=int8) >>> y.a array([255], dtype=uint8)
Creating a view on a structured array so it can be used in calculations
>>> x = np.array([(1, 2),(3,4)], dtype=[('a', np.int8), ('b', np.int8)]) >>> xv = x.view(dtype=np.int8).reshape(-1,2) >>> xv array([[1, 2], [3, 4]], dtype=int8) >>> xv.mean(0) array([2., 3.])
Making changes to the view changes the underlying array
>>> xv[0,1] = 20 >>> x array([(1, 20), (3, 4)], dtype=[('a', 'i1'), ('b', 'i1')])
Using a view to convert an array to a recarray:
>>> z = x.view(np.recarray) >>> z.a array([1, 3], dtype=int8)
Views share data:
>>> x[0] = (9, 10) >>> z[0] np.record((9, 10), dtype=[('a', 'i1'), ('b', 'i1')])
Views that change the dtype size (bytes per entry) should normally be avoided on arrays defined by slices, transposes, fortran-ordering, etc.:
>>> x = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.int16) >>> y = x[:, ::2] >>> y array([[1, 3], [4, 6]], dtype=int16) >>> y.view(dtype=[('width', np.int16), ('length', np.int16)]) Traceback (most recent call last): ... ValueError: To change to a dtype of a different size, the last axis must be contiguous >>> z = y.copy() >>> z.view(dtype=[('width', np.int16), ('length', np.int16)]) array([[(1, 3)], [(4, 6)]], dtype=[('width', '<i2'), ('length', '<i2')])
However, views that change dtype are totally fine for arrays with a contiguous last axis, even if the rest of the axes are not C-contiguous:
>>> x = np.arange(2 * 3 * 4, dtype=np.int8).reshape(2, 3, 4) >>> x.transpose(1, 0, 2).view(np.int16) array([[[ 256, 770], [3340, 3854]], [[1284, 1798], [4368, 4882]], [[2312, 2826], [5396, 5910]]], dtype=int16)
- class mupif.RefQuantity
Bases:
UtilityQuantity with data stored somewhere else. Abstract class, to be subclassed.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.RemoteAppRecord(app, appTunnel, jobMan, jobManTunnel, jobID)
Bases:
objectClass keeping internal data on remote application. The data contain: * appTunnel: reference to application ssh tunnel * jobMan: reference to jobManager * jobManTunnel: reference to jobManager tunnel representation * jobID: jobID of application .. automethod:: __init__
- appendNextApplication(app, appTunnel, jobID)
Append next application on existing instance :param Application app: application instance :param subprocess.Popen appTunnel: ssh tunnel subprocess representing ssh tunnel to application process :param string jobID: application jobID
- getApplication(num=0)
Returns application instance :param int num: number of application, default 0 :return: Instance of Application
- getApplicationUri(num=0)
Returns application uri :param int num: number of application, default 0 :return: uri
- getJobID(num=0)
- getJobManager()
- terminateAll()
Terminates all remote applications in app[] including their ssh tunnels. Terminates also jobManager and the associated ssh tunnel.
- terminateApp(num)
Terminates app[num] and its ssh tunnel. Job manager and its tunnel remains untouched. :param int num: number of application
- class mupif.RemoteJobManager(*args, **kwargs)
Bases:
RemoteModelServer- terminate()
Terminates the application. Terminates the allocated job at jobManager
- class mupif.RemoteModel(decoratee, jobMan=None, jobID=None)
Bases:
objectRemote Application instances are normally represented by auto generated pyro proxy. However, when application is allocated using JobManager or ssh tunnel, the proper termination of the tunnel or job manager task is required.
This class is a decorator around pyro proxy object represeting application storing the reference to job manager and related jobID or/and ssh tunnel.
These extermal attributes could not be injected into Application instance, as it is remote instance (using proxy) and the termination of job and tunnel has to be done from local computer, which has the neccesary communication link established (ssh tunnel in particular, when port translation takes place)
- getJobID()
- terminate()
Terminates the application. Terminates the allocated job at jobManager
- class mupif.RemoteModelServer(decoratee)
Bases:
objectRemote jobManager instances are normally represented by auto generated pyro proxy. However, when ssh tunneled connection is established to connect to remote job manager, its instance must be properly terminated. This class is a decorator around pyro proxy object represeting jobManager storing the reference to the ssh tunnel established. Note in case of VPN or direct (plain) connection, the plain Pyro proxy should be used.
The attribute could not be injected into remote instance (using proxy) as the termination has to be done from local computer, where the ssh tunnel has been created. Also different connections (proxies) to the same jobManager can exist.
- terminate()
Terminates the application. Terminates the allocated job at jobManager
- class mupif.SimpleJobManager(*args, **kwargs)
Bases:
ModelServer- class ActiveJob(proc: 'typing.Union[subprocess.Popen, multiprocessing.Process]', uri: 'str', starttime: 'float', timeout: 'int', user: 'str', port: 'int', jobLogName: 'str', remoteLogUri: 'str')
Bases:
object- jobLogName: str
- port: int
- proc: Popen | Process
- remoteLogUri: str
- starttime: float
- timeout: int
- uri: str
- user: str
- class SpawnedProcessArgs(*, uriFileName: str, nsUri: str, appName: str, jobID: str, cwd: str, appClass: object)
Bases:
BaseModelArgs passed to child processes via Popen
- appClass: object
- appName: str
- cwd: str
- jobID: str
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'appClass': FieldInfo(annotation=object, required=True), 'appName': FieldInfo(annotation=str, required=True), 'cwd': FieldInfo(annotation=str, required=True), 'jobID': FieldInfo(annotation=str, required=True), 'nsUri': FieldInfo(annotation=str, required=True), 'uriFileName': FieldInfo(annotation=str, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- nsUri: str
- pickle()
- classmethod unpickle(data)
- uriFileName: str
- allocateJob(user, *, remoteLogUri=None, ticket=None)
Allocates a new job.
Modified to accept optional ticket for preallocated resource. Thread safe
- Except:
unable to start a thread, no more resources
- dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
Add dunder methods based on the fields defined in the class.
Examines PEP 526 __annotations__ to determine fields.
If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.
- getApplicationSignature()
- getJobStatus(jobID)
Returns the status of the job.
- Parameters:
jobID (str) – jobID
- getJobWorkDir(jobID)
Returns working directory of a job with given ID.
- Parameters:
jobID (str) –
- Returns:
job working directory
- Return type:
str
- getLogFile(jobID)
- getModelMetadata()
- getNSName()
- getName()
- getNumberOfFreeJobs()
Returns number of free jobs to be allocated.
- getPyroFile(jobID, filename, mode='r', buffSize=1048576)
- getStatus() List[JobStatus]
- getStatusExtended() ModelServerStatus
- preAllocate(requirements=None)
Allows to pre-allocate(reserve) the resource. Returns ticket id (as promise) to finally allocate resource. The requirements is an optional job-man specific dictionary with additional parameters (such as number of cpus, etc). The returned ticket is valid only for fixed time period (suggest 10[s]), then should expire. Thread safe
- registerPyro(*, daemon, ns, uri, appName, exclusiveDaemon=False, externalDaemon=None)
Possibility to register the Pyro daemon and nameserver.
- Parameters:
daemon (Pyro5.api.Daemon) – Optional pyro daemon
ns (Pyro4.naming.Nameserver) – Optional nameserver
uri (string) – Optional URI of receiver
appName (string) –
exclusiveDaemon (bool) – Optional parameter when damon was allocated externally.
- runServer()
- terminate(force=False)
Terminates job manager itself.
- terminateAllJobs()
Terminates all registered jobs, frees the associated recources.
- terminateJob(jobID)
Terminates the given job, frees the associated recources.
- ticketExpireTimeout = 10
- uploadFile(jobID, filename, pyroFile)
- class mupif.SingleFileTemporalField(*a, metadata: BaseMeta = BaseMeta(), h5path: str = '', h5uri: str | None = None, mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] = 'readonly', pyroIds: List[str] = [], fieldMeta: List[_FieldMetadata] = [])
Bases:
TemporalField,HeavyDataBase- ModeChoice
alias of
Literal[‘readonly’, ‘readwrite’, ‘overwrite’, ‘create’, ‘create-memory’, ‘copy-readwrite’]
- addField(field, userMetadata)
- allocateDataset(*, h5loc, shape, **kw)
- cloneHandle(newPath: str = '')
Return clone of the handle; the underlying storage is copied into newPath (or a temporary file, if not given). All handle attributes (besides
h5path) are preserved.
- closeData()
Flush and close the backing HDF5 file;
unregister all contexts from Pyro (if registered)
- evaluate(time: ~astropy.units.quantity.Quantity, positions, eps: float = 0.0, epsTime=<Quantity 0. s>)
- exposeData()
If self is registered in a Pyro daemon, the underlying HDF5 file will be exposed as well. This modifies the
h5uriattribute which causes transparent download of the HDF5 file when theHeavyDataBaseobject is reconstructed remotely by Pyro (e.g. by usingBareData.copyRemote).
- fieldMeta: List[_FieldMetadata]
- getCachedTimes()
- getField(time: ~astropy.units.quantity.Quantity, epsTime=<Quantity 0. s>)
- h5path: str
- h5uri: Optional[str]
- mode: HeavyDataBase_ModeChoice
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'fieldMeta': FieldInfo(annotation=List[_FieldMetadata], required=False, default=[]), 'h5path': FieldInfo(annotation=str, required=False, default=''), 'h5uri': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'mode': FieldInfo(annotation=Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'], required=False, default='readonly'), 'pyroIds': FieldInfo(annotation=List[str], required=False, default=[], exclude=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- moveStorage(new_h5path)
Moves underlying storage in the filesystem to the new path new_h5path, and sets the
h5pathattribute to the new path.
- openData(mode=typing.Optional[typing.Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite']])
- openStorage(mode: Literal['readonly', 'readwrite', 'overwrite', 'create', 'create-memory', 'copy-readwrite'] | None = None)
- pyroIds: List[str]
- repack()
Repack the underlying storage (experimental, untested). Data must not be open.
- timeMetadata(time, epsTime=<Quantity 0. s>) dict
- writeXdmf(xdmf=None, timeUnit=Unit('s'))
- class mupif.String(*, metadata: BaseMeta = BaseMeta(), value: NDArray[Any, str_], dataID: DataID, valueType: ValueType = None)
Bases:
Data,DbDictable- static from_db_dict(d)
- getDataID()
- getValue()
- getValueType()
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dataID': FieldInfo(annotation=DataID, required=True), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta()), 'value': FieldInfo(annotation=NDArray, required=True), 'valueType': FieldInfo(annotation=ValueType, required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- to_db_dict(dialect: Literal['edm'] | None = None) dict[str, Any]
- to_db_dict_impl()
- value: NDArray[Any, str_]
- classmethod value_validator(v)
- class mupif.TemporalField(*a, metadata: BaseMeta = BaseMeta(), fieldMeta: List[_FieldMetadata] = [])
Bases:
Data- addField(field, userMetadata)
- evaluate(time: ~astropy.units.quantity.Quantity, positions, eps: float = 0.0, epsTime=<Quantity 0. s>)
- fieldMeta: List[_FieldMetadata]
- getCachedTimes()
- getField(time: ~astropy.units.quantity.Quantity, epsTime=<Quantity 0. s>)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'fieldMeta': FieldInfo(annotation=List[_FieldMetadata], required=False, default=[]), 'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta())}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- timeMetadata(time, epsTime=<Quantity 0. s>) dict
- class mupif.TemporalProperty(*, metadata: IOMeta | None = None, quantity: Quantity | RefQuantity, valueType: ValueType = ValueType.Scalar, propID: DataID, times: Quantity)
Bases:
Property,DbDictable- dataDigest(*args)
- static from_db_dict(d)
- getDataID()
Returns DataID of property. :rtype: DataID
- getQuantity()
- getValue()
- getValueType()
Returns ValueType of the field, e.g. scalar, vector, tensor.
- Returns:
Returns value type of the receiver
- Return type:
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=Union[IOMeta, NoneType], required=False, default=None), 'propID': FieldInfo(annotation=DataID, required=True), 'quantity': FieldInfo(annotation=Union[Quantity, RefQuantity], required=True), 'times': FieldInfo(annotation=Quantity, required=True), 'valueType': FieldInfo(annotation=ValueType, required=False, default=<ValueType.Scalar: 1>)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- propID: dataid.DataID
- property q
- quantity: Union[units.Quantity, units.RefQuantity]
- to_db_dict(dialect: Literal['edm'] | None = None) dict[str, Any]
- to_db_dict_impl()
- property unit
- property value
- class mupif.Tetrahedron_3d_lin(*, number: int, label: int | None = None, vertices: Tuple[int, ...], mesh: Mesh | None = None)
Bases:
CellUnstructured 3d tetrahedral element with linear interpolation.
- containsPoint(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) bool
Check if a cell contains a point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if cell contains a given point
- Return type:
bool
- getBBox(relPad=1e-05)
Return bounding box. The box is by default slightly enlarged via relPad to avoid finite-precision issues when testing for a boundary point being inside the box.
- Parameters:
relPad (float) – relative padding of the box; tight (geometrical) bbox will be enlarged along each axis by relPad times size along that axis, in both directions.
- Returns:
Returns a bounding box of the receiver
- Return type:
- static getClassForCellGeometryType(cgt)
Return class object (not instance) for given cell geometry type. Does introspection of all subclasses of Cell caches the result.
- classmethod getGeometryType() CGT
Returns geometry type of receiver.
- Returns:
Returns geometry type of receiver
- Return type:
CellGeometryType
- getMeshioGeometryStr() str
- getNumberOfVertices()
- Returns:
Number of vertices
- Return type:
int
- getTransformationJacobian(coords) float
Returns the transformation jacobian (the determinant of jacobian) of the receiver
- Parameters:
coords (tuple) – local (parametric) coordinates of the point
- Returns:
jacobian
- Return type:
float
- getVertices()
- Returns:
The list of cell vertices
- Return type:
tuple
- glob2loc(coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Converts global coordinate to local (area) coordinate.
- Parameters:
coords (tuple) – A coordinate in global system
- Returns:
local (area) coordinate
- Return type:
tuple
- interpolate(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)], vertexValues: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[4, 1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Interpolates given vertex values to a given point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
vertexValues (tuple) – A tuple containing vertex values
- Returns:
Interpolated value at a given point
- Return type:
tuple
- label: Optional[int]
Cell label, arbitrary unique number.
- loc2glob(lc: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Converts local (parametric) coordinates to global ones
- Parameters:
lc (tuple) – A local coordinate
- Returns:
global coordinate
- Return type:
tuple
- mesh: Optional['Mesh']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'mesh': FieldInfo(annotation=Union[Mesh, NoneType], required=False, default=None, exclude=True), 'number': FieldInfo(annotation=int, required=True), 'vertices': FieldInfo(annotation=Tuple[int, ...], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local cell number; local numbering should start from 0 and should be continuous.
- vertices: Tuple[int, ...]
Cell vertices (local numbers)
- class mupif.TimeStep(*, number: int = 1, unit: Unit | None = None, time: Quantity, dt: Quantity, targetTime: Quantity)
Bases:
BareDataClass representing a time step. The folowing attributes are used to characterize a time step:
||- - -||(time-dt)- - - i-th time step(dt) - - -||(time)- - - -||- - - -||(targetTime)
Note: Individual models (applications) assemble theit governing equations at specific time, called asssemblyTime, this time is reported by individual models. For explicit model, asssembly time is equal to timeStep.time-timestep.dt, for fully implicit model, assembly time is equal to timeStep.time
- __init__(**data: Any) None
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.
- classmethod conv_times(t, info: ValidationInfo)
- getNumber()
- Returns:
Receiver’s solution step number
- Return type:
int
- getTargetTime()
- Returns:
Target time
- Return type:
units.Quantity
- getTime()
- Returns:
Time
- Return type:
units.Quantity
- getTimeIncrement()
- Returns:
Time increment
- Return type:
units.Quantity
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'dt': FieldInfo(annotation=Quantity, required=True), 'number': FieldInfo(annotation=int, required=False, default=1), 'targetTime': FieldInfo(annotation=Quantity, required=True), 'time': FieldInfo(annotation=Quantity, required=True), 'unit': FieldInfo(annotation=Union[Unit, NoneType], required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
- class mupif.Timer
Bases:
objectClass for measuring time.
- __enter__()
Remembers time at calling this function.
- __exit__(*args)
Remembers time at calling this function and calculates the difference to __enter__().
- class mupif.Triangle_2d_lin(*, number: int, label: int | None = None, vertices: Tuple[int, ...], mesh: Mesh | None = None)
Bases:
CellUnstructured 2D triangular element with linear interpolation Node numbering convention:
2 | | | | 0—–1
- containsPoint(point)
Check if a cell contains a point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if cell contains a given point
- Return type:
bool
- getBBox(relPad=1e-05)
Return bounding box. The box is by default slightly enlarged via relPad to avoid finite-precision issues when testing for a boundary point being inside the box.
- Parameters:
relPad (float) – relative padding of the box; tight (geometrical) bbox will be enlarged along each axis by relPad times size along that axis, in both directions.
- Returns:
Returns a bounding box of the receiver
- Return type:
- static getClassForCellGeometryType(cgt)
Return class object (not instance) for given cell geometry type. Does introspection of all subclasses of Cell caches the result.
- classmethod getGeometryType() CGT
Returns geometry type of receiver.
- Returns:
Returns geometry type of receiver
- Return type:
CellGeometryType
- getMeshioGeometryStr() str
- getNumberOfVertices()
- Returns:
Number of vertices
- Return type:
int
- getTransformationJacobian(coords)
Returns the transformation jacobian (the determinant of jacobian) of the receiver
- Parameters:
coords (tuple) – local (parametric) coordinates of the point
- Returns:
jacobian
- Return type:
float
- getVertices()
- Returns:
The list of cell vertices
- Return type:
tuple
- glob2loc(coords)
Converts global coordinate to local (area) coordinate.
- Parameters:
coords (tuple) – A coordinate in global system
- Returns:
local (area) coordinate
- Return type:
tuple
- interpolate(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)], vertexValues: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[3, 1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Interpolates given vertex values to a given point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
vertexValues (tuple) – A tuple containing vertex values
- Returns:
Interpolated value at a given point
- Return type:
tuple
- label: Optional[int]
Cell label, arbitrary unique number.
- loc2glob(lc)
Converts local (parametric) coordinates to global ones.
- Parameters:
lc (tuple) – A local coordinate
- Returns:
global coordinate
- Return type:
tuple
- mesh: Optional['Mesh']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'mesh': FieldInfo(annotation=Union[Mesh, NoneType], required=False, default=None, exclude=True), 'number': FieldInfo(annotation=int, required=True), 'vertices': FieldInfo(annotation=Tuple[int, ...], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local cell number; local numbering should start from 0 and should be continuous.
- vertices: Tuple[int, ...]
Cell vertices (local numbers)
- class mupif.Triangle_2d_quad(*, number: int, label: int | None = None, vertices: Tuple[int, ...], mesh: Mesh | None = None)
Bases:
CellUnstructured 2D triangular element with quadratic interpolation Node numbering convention:
2 | | 5 4 | | 0–3—1
- containsPoint(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)])
Check if a cell contains a point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
- Returns:
Returns True if cell contains a given point
- Return type:
bool
- getBBox(relPad=1e-05)
Return bounding box. The box is by default slightly enlarged via relPad to avoid finite-precision issues when testing for a boundary point being inside the box.
- Parameters:
relPad (float) – relative padding of the box; tight (geometrical) bbox will be enlarged along each axis by relPad times size along that axis, in both directions.
- Returns:
Returns a bounding box of the receiver
- Return type:
- static getClassForCellGeometryType(cgt)
Return class object (not instance) for given cell geometry type. Does introspection of all subclasses of Cell caches the result.
- classmethod getGeometryType() CGT
Returns geometry type of receiver.
- Returns:
Returns geometry type of receiver
- Return type:
CellGeometryType
- getMeshioGeometryStr() str
- getNumberOfVertices()
- Returns:
Number of vertices
- Return type:
int
- getTransformationJacobian(coords)
Returns the transformation jacobian (the determinant of jacobian) of the receiver
- Parameters:
coords (tuple) – local (parametric) coordinates of the point
- Returns:
jacobian
- Return type:
float
- getVertices()
- Returns:
The list of cell vertices
- Return type:
tuple
- glob2loc(coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Converts global coordinate to local (area) coordinate.
- Parameters:
coords (tuple) – A coordinate in global system
- Returns:
local (area) coordinate
- Return type:
tuple
- interpolate(point: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)], vertexValues: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[6, 1-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Interpolates given vertex values to a given point.
- Parameters:
point (tuple) – 1D/2D/3D position vector
vertexValues (tuple) – A tuple containing vertex values
- Returns:
Interpolated value at a given point
- Return type:
tuple
- label: Optional[int]
Cell label, arbitrary unique number.
- loc2glob(lc: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)]) float64'>)]
Converts local (parametric) coordinates to global ones.
- Parameters:
lc (tuple) – A local coordinate
- Returns:
global coordinate
- Return type:
tuple
- mesh: Optional['Mesh']
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'mesh': FieldInfo(annotation=Union[Mesh, NoneType], required=False, default=None, exclude=True), 'number': FieldInfo(annotation=int, required=True), 'vertices': FieldInfo(annotation=Tuple[int, ...], required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local cell number; local numbering should start from 0 and should be continuous.
- vertices: Tuple[int, ...]
Cell vertices (local numbers)
- class mupif.UnitProxy
Bases:
object
- class mupif.UnstructuredMesh(*, mapping: Any = None, unit: str | Unit | None = None, vertexList: List[Vertex] = [], cellList: List[Cell] = [])
Bases:
Mesh,HeavyConvertibleRepresents unstructured mesh. Maintains the list of vertices and cells.
The class contains:
vertexList: list of vertices
cellList: list of interpolation cells
_vertexOctree: vertex spatial localizer
_cellOctree: cell spatial localizer
_vertexDict: vertex dictionary
_cellDict: cell dictionary
- __init__(**kw)
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.
- __buildVertexLabelMap__()
Create a custom dictionary between vertex’s label and Vertex instance.
- __buildCellLabelMap__()
Create a custom dictionary between cell’s label and Cell instance.
- asHdf5Object(parentgroup, heavyMesh=False)
Return the instance as HDF5 object. Complementary to
makeFromHdf5Objectwhich will restore the instance from that data.
- asVtkUnstructuredGrid()
Return an object as a vtk.vtkUnstructuredMesh instance.
- Returns:
vtk
- Return type:
vtk.vtkUnstructuredGrid()
Note
This method uses the compiled vtk module (which is a wrapper atop the c++ VTK library) – in contrast to
UnstructuredMesh.getVTKRepresentation, which uses the pyvtk module (python-only implementation of VTK i/o supporting only VTK File Format version 2).
- cellLabel2Number(label: int) int
- cells()
- copyToHeavy(*, h5grp)
- dataDigest()
Internal function returning hash digest of all internal data, for the purposes of identity test.
- getCell(i) Cell
See
Mesh.getCell()
- getCellLocalizer()
Get the cell localizer.
- Returns:
Returns the cell localizer.
- Return type:
- getCells()
Return all cells as 2x numpy.array; each i-th row contains vertex indices for i-th cell. Does in 2 passes, first to determine maximum number of vertices per cell (to shape the field accordingly). For cells with less vertices than the maximum, excess ones are assigned the invalid value of -1.
- Returns:
(cell_types,cell_vertices)
- Return type:
(numpy.array,numpy.array)
Note
This method has not been tested yet.
- getGlobalBBox()
- getMapping()
Get mesh mapping.
- Returns:
The mapping associated to a mesh
- Return type:
defined by API
- getNumberOfCells() int
- getNumberOfVertices() int
- getVTKRepresentation()
Get VTK representatnion of the mesh.
return: VTK representation of the receiver. Requires pyvtk module. :rtype: pyvtk.UnstructuredGrid
- getVertex(i: int) Vertex
See
Mesh.getVertex()
- getVertices()
Return all vertex coordinates as 2D (Nx3) numpy.array; each i-th row contains 3d coordinates of the i-th vertex.
- Returns:
vertices
- Return type:
numpy.array
Note
This method has not been tested yet.
- giveVertexLocalizer()
- classmethod isHere(*, h5grp) bool
- static makeFromHdf5group(h5grp)
Create new
Meshinstance from given hdf5 object. Complementary toasHdf5Object.Constructs HeavyUnstructuredMesh if data are saved in that format.
- Returns:
new instance
- Return type:
Meshor its subclass
- classmethod makeFromHeavy(*, h5grp, indices)
- static makeFromMeshioMesh(mesh)
- static makeFromMeshioPointsCells(points, cells)
- static makeFromPyvtkUnstructuredGrid(ugr)
Create a new instance of
UnstructuredMeshbased on pyvtk.UnstructuredGrid object. Cell types are mapped between pyvtk and mupif (supported: triangle, tetra, quad, hexahedron).- Parameters:
ugr – instance of pyvtk.UnstructuredGrid
- Returns:
new instance of
UnstructuredMesh
- static makeFromVtkUnstructuredGrid(ugrid)
Create a new instance of
UnstructuredMeshbased on VTK’s unstructured grid object. Cell types are mapped between VTK and mupif (supported: vtkTriangle, vtkQuadraticTriangle, vtkQuad, vtkTetra, vtkHexahedron).- Parameters:
ugrid – instance of vtk.vtkUnstructuredGrid
- Returns:
new instance of
UnstructuredMesh
- mapping: Any
- merge(mesh: Mesh)
Merges receiver with a given mesh. This is based on merging mesh entities (vertices, cells) based on their labels, as they refer to global IDs of each entity, that should be unique.
The procedure used here is based on creating a dictionary for every componenet from both meshes, where the key is component label so that the entities with the same ID could be easily identified.
- Parameters:
mesh (Mesh) – Source mesh for merging
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'cellList': FieldInfo(annotation=List[Cell], required=False, default=[]), 'mapping': FieldInfo(annotation=Any, required=False, default=None), 'unit': FieldInfo(annotation=Union[str, Unit, NoneType], required=False, default=None), 'vertexList': FieldInfo(annotation=List[Vertex], required=False, default=[])}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- setup(vertexList: List[Vertex], cellList: List[Cell]) None
Initializes the receicer according to given vertex and cell lists.
- Parameters:
vertexList (list) – A tuple of vertices
cellList (list) – A tuple of cells
- toHdf5Group(group)
- toMeshioMesh()
- toMeshioPointsCells()
- unit: Optional[Union[str, units.Unit]]
- vertexLabel2Number(label)
- vertexList: List[vertex.Vertex]
- vertices()
- class mupif.Utility
Bases:
ObjectBaseBase class existing for hieararchy structure only. Derived classes provide some functionality which does not fit into Process or BareData/Data.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.ValueType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
IntEnum- Scalar = 1
- ScalarArray = 4
- Tensor = 3
- TensorArray = 6
- Vector = 2
- VectorArray = 5
- as_integer_ratio()
Return integer ratio.
Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()
Returns self, the complex conjugate of any int.
- denominator
the denominator of a rational number in lowest terms
- static fromNumberOfComponents(i)
- Parameters:
i (int) – number of components
- Returns:
value type corresponding to the number of components
RuntimeError is raised if i does not match any value known.
- from_bytes(byteorder='big', *, signed=False)
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- getNumberOfComponents()
- static getValueFromQuantity(q)
- imag
the imaginary part of a complex number
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class mupif.Vertex(*, number: int, label: int | None = None, coords: ~numpydantic.vendor.nptyping.base_meta_classes.NDArray[~numpydantic.vendor.nptyping.base_meta_classes.Shape[2-3], (<class 'numpy.float16'>, <class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.float32'>, <class 'numpy.float64'>)])
Bases:
BareDataRepresent a vertex. Vertices define the geometry of interpolation cells. Vertex is characterized by its position, number and label. Vertex number is locally assigned number, while label is a unique number referring to source application.
- __init__(**data: Any) None
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.
- __repr__()
- Returns:
Receiver’s number, label, coordinates
- Return type:
string
- coords: float64'>)]
3D position vector of a vertex
- getBBox()
- Returns:
Receiver’s bounding-box (containing only one point)
- Return type:
- getCoordinates() float64'>)]
- Returns:
Receiver’s coordinates
- Return type:
tuple
- getNumber() int
- Returns:
Number of the instance
- Return type:
int
- label: int | None
Vertex label
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'coords': FieldInfo(annotation=NDArray, required=True), 'label': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'number': FieldInfo(annotation=int, required=True)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- number: int
Local vertex number
- class mupif.WithMetadata(*, metadata: BaseMeta = BaseMeta())
Bases:
ObjectBaseClass representing a base Mupif object, with metadata.
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'metadata': FieldInfo(annotation=BaseMeta, required=False, default=BaseMeta())}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context: Any) None
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- class mupif.Workflow(*, metadata=None)
Bases:
ModelAn abstract class representing a workflow and its interface (API).
The purpose of this class is to represent a workflow, its abstract services for data exchange and steering. This interface has to be implemented/provided by any workflow. The Workflow class inherits from Application allowing to treat any workflow as model(application) in high-level workflow.
- __init__(*, metadata=None)
Constructor. Initializes the workflow
- Parameters:
metadata (dict) – Optionally pass metadata.
- appName: str | None
- static checkModelRemoteResource(jobmanagername)
- static checkModelRemoteResourcesByMetadata(models_md)
- exclusiveDaemon: bool
- finishStep(tstep)
Called after a global convergence within a time step is achieved.
- Parameters:
tstep (timestep.TimeStep) – Solution step
- generateModelDependencies()
- get(objectTypeID, time=None, objectID='')
Returns the requested object at given time. Object is identified by id.
- Parameters:
objectTypeID (DataID) – Identifier of the object
time (Physics.PhysicalQuantity) – Target time
objectID (str) – Identifies object with objectID (optional, default 0)
- Returns:
Returns requested object.
- getAPIVersion()
- Returns:
Returns the supported API version
- Return type:
str, int
- getApplicationSignature()
Get application signature.
- Returns:
Returns the application identification
- Return type:
str
- getAssemblyTime(tstep)
Returns the assembly time related to given time step. The registered fields (inputs) should be evaluated in this time.
- Parameters:
tstep (timestep.TimeStep) – Solution step
- Returns:
Assembly time
- Return type:
Physics.PhysicalQuantity, timestep.TimeStep
- getCriticalTimeStep()
Returns a critical time step for an application.
- Returns:
Returns the actual (related to current state) critical time step increment
- Return type:
Physics.PhysicalQuantity
- getDictOfModels()
- Return type:
dict[model.Model, model.RemoteModel, Workflow]
- getExecutionTargetTime()
- getExecutionTimestepLength()
- getFieldURI(fieldID, time, objectID='')
Returns the uri of requested field at given time. Field is identified by fieldID.
- Parameters:
fieldID (DataID) – Identifier of the field
time (Physics.PhysicalQuantity) – Target time
objectID (str) – Identifies field with objectID (optional, default 0)
- Returns:
Requested field uri
- Return type:
Pyro5.api.URI
- getJobID()
- getJobManager(name)
- getListOfModelLabels()
- Return type:
list of str
- getListOfModels()
- Return type:
list[model.Model, model.RemoteModel, Workflow]
- getURI()
- Returns:
Returns the application URI or None if application not registered in Pyro
- Return type:
str
- initialize(*, workdir='', metadata=None, validateMetaData=True, **kwargs)
Initializes application, i.e. all functions after constructor and before run.
- Parameters:
workdir (str) – Optional parameter for working directory
metadata (dict) – Optional dictionary used to set up metadata (can be also set by setMetadata() )
validateMetaData (bool) – Defines if the metadata validation will be called
- isSolved()
Check whether solve has completed.
- Returns:
Returns true or false depending whether solve has completed when executed in background.
- Return type:
bool
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set: set[str] | None = None, **values: Any) Self
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed.
- !!! note
model_construct() generally respects the model_config.extra setting on the provided model. That is, if model_config.extra == ‘allow’, then all extra passed values are added to the model instance’s __dict__ and __pydantic_extra__ fields. If model_config.extra == ‘ignore’ (the default), then all extra passed values are ignored. Because no validation is performed with a call to model_construct(), having model_config.extra == ‘forbid’ does not result in an error if extra values are passed, but they will be ignored.
- Args:
- _fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
- Returns:
A new instance of the Model class with validated data.
- model_copy(*, update: dict[str, Any] | None = None, deep: bool = False) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- Args:
- update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
- Returns:
New model instance.
- model_dump(*, mode: Literal['json', 'python'] | str = 'python', include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) dict[str, Any]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent: int | None = None, include: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, exclude: Set[int] | Set[str] | Mapping[int, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | Mapping[str, Set[int] | Set[str] | Mapping[int, IncEx | Literal[True]] | Mapping[str, IncEx | Literal[True]] | Literal[True]] | None = None, context: Any | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False) str
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
- Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. by_alias: Whether to serialize using field aliases. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or None if config.extra is not set to “allow”.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'appName': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'exclusiveDaemon': FieldInfo(annotation=bool, required=False, default=False), 'metadata': FieldInfo(annotation=Union[WorkflowMeta, NoneType], required=False, default=None), 'pyroDaemon': FieldInfo(annotation=Union[Any, NoneType], required=False, default=None), 'pyroNS': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'pyroURI': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'workDir': FieldInfo(annotation=str, required=False, default=''), 'workflowMonitor': FieldInfo(annotation=Any, required=False, default=None)}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- property model_fields_set: set[str]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias: bool = True, ref_template: str = '#/$defs/{model}', schema_generator: type[pydantic.json_schema.GenerateJsonSchema] = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: ~typing.Literal['validation', 'serialization'] = 'validation') dict[str, Any]
Generates a JSON schema for a model class.
- Args:
by_alias: Whether to use attribute aliases or not. ref_template: The reference template. schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params: tuple[type[Any], ...]) str
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Args:
- params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int], the value (str, int) would be passed to params.
- Returns:
String representing the new class where params are passed to cls as type variables.
- Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
- model_post_init(context: Any, /) None
We need to both initialize private attributes and call the user-defined model_post_init method.
- classmethod model_rebuild(*, force: bool = False, raise_errors: bool = True, _parent_namespace_depth: int = 2, _types_namespace: dict[str, Any] | None = None) bool | None
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during the initial attempt to build the schema, and automatic rebuilding fails.
- Args:
force: Whether to force the rebuilding of the model schema, defaults to False. raise_errors: Whether to raise errors, defaults to True. _parent_namespace_depth: The depth level of the parent namespace, defaults to 2. _types_namespace: The types namespace, defaults to None.
- Returns:
Returns None if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returns True if rebuilding was successful, otherwise False.
- classmethod model_validate(obj: Any, *, strict: bool | None = None, from_attributes: bool | None = None, context: Any | None = None) Self
Validate a pydantic model instance.
- Args:
obj: The object to validate. strict: Whether to enforce types strictly. from_attributes: Whether to extract data from object attributes. context: Additional context to pass to the validator.
- Raises:
ValidationError: If the object could not be validated.
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data: str | bytes | bytearray, *, strict: bool | None = None, context: Any | None = None) Self
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Args:
json_data: The JSON data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj: Any, *, strict: bool | None = None, context: Any | None = None) Self
Validate the given object with string data against the Pydantic model.
- Args:
obj: The object containing string data to validate. strict: Whether to enforce types strictly. context: Extra variables to pass to the validator.
- Returns:
The validated Pydantic model.
- printListOfModels()
- pyroDaemon: Any | None
- pyroNS: str | None
- pyroURI: str | None
- registerModel(mmodel, label=None)
- Parameters:
mmodel (model.Model or model.RemoteModel or Workflow) –
label (str or None) – Explicit label of the model/workflow, given by the parent workflow.
- registerPyro(*, daemon, ns, uri, appName=None, exclusiveDaemon=False, externalDaemon=None)
Register the Pyro daemon and nameserver. Required by several services
- Parameters:
pyroDaemon (Pyro5.api.Daemon) – Optional pyro daemon
pyroNS (Pyro5.naming.Nameserver) – Optional nameserver
pyroURI (string) – Optional URI of receiver
appName (string) – Optional application name. Used for removing from pyroNS
exclusiveDaemon (bool) – Optional parameter when daemon was allocated externally.
- removeApp(nameServer=None, appName=None)
Removes (unregisters) application from the name server.
- Parameters:
nameServer (Pyro5.naming.Nameserver) – Optional instance of a nameServer
appName (str) – Optional name of the application to be removed
- restoreState(tstep)
Restore the saved state of an application. :param timestep.TimeStep tstep: Solution step
- set(obj, objectID='')
Registers the given (remote) object in application.
- Parameters:
obj (property.Property or field.Field or function.Function or pyrofile.PyroFile or heavydata.HeavyDataHandle) – Remote object to be registered by the application
objectID (str) – Identifies object with objectID (optional, default 0)
- setJobID(jobid)
- solve(runInBackground=False)
Solves the workflow.
The default implementation solves the problem in series of time steps using solveStep method (inheritted) until the final time is reached.
- Parameters:
runInBackground (bool) – optional argument, default False. If True, the solution will run in background (in separate thread or remotely).
- solveStep(tstep, stageID=0, runInBackground=False)
Solves the problem for given time step.
Proceeds the solution from actual state to given time. The actual state should not be updated at the end, as this method could be called multiple times for the same solution step until the global convergence is reached. When global convergence is reached, finishStep is called and then the actual state has to be updated. Solution can be split into individual stages identified by optional stageID parameter. In between the stages the additional data exchange can be performed. See also wait and isSolved services.
- Parameters:
tstep (timestep.TimeStep) – Solution step
stageID (int) – optional argument identifying solution stage (default 0)
runInBackground (bool) – optional argument, defualt False. If True, the solution will run in background (in separate thread or remotely).
- storeState(tstep)
Store the solution state of an application.
- Parameters:
tstep (timestep.TimeStep) – Solution step
- terminate()
Terminates the application. Shutdowns daemons if created internally.
- updateAndPassMetadata(dictionary: dict)
- updateStatus(status, progress=0)
Updates the workflow status. The status is submitted to workflow monitor. The self.workflowMonitor should be (proxy) to workflowManager :param str status: string describing the workflow status (initialized, running, failed, finished) :param int progress: integer number indicating execution progress (in percent)
- wait()
Wait until solve is completed when executed in background.
- workDir: str
- workflowMonitor: Any