Setting#
- class Setting(parameter=None, value=None, read_only=False, path='', source=None)#
Bases:
BaseModel
Physical quantity represented as a Parameter attached to a numerical value.
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.
Module:
exa.common.data.parameter
Attributes
Element-wise indices of the parameter in
self
.Label used as pretty identifier for display purposes, same as label of
parameter
.Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Name used as identifier, same as name of
parameter
.Parent label of the parameter of
self
.Parent name of the parameter of
self
.Return the source for this Setting's value.
SI unit of the
value
, if applicable, same as unit ofparameter
.The parameter this Setting represents.
Data value attached to the parameter.
Indicates if the attribute is read-only.
Path in the settings tree (starting from the root
SettingNode
) for this setting.Methods
Utility for creating an element-wise parameter for a single value in a collection valued parameter.
Return a one-sided difference between two sets of Settings, prioritising values in first.
get_by_name
merge
This function is meant to behave like a BaseModel method to initialise private attributes.
remove_by_name
replace
Create a new setting object with updated value and source.
validate_parameter_value_after
Copy of self with the parameter name replaced by the path name.
- Parameters:
- value: ObservationValue#
Data value attached to the parameter.
- _source: SourceType = ModelPrivateAttr()#
The source for this Setting value. May contain an observation (ObservationDefinition or ObservationData) or a source-dict (e.g.
{"type": "configuration_source", "configurator": "defaults_from_yml"}
). By default,None
, which denotes the source not being specified (e.g. hardcoded defaults). The source is stored in a private attribute and thus is never serialized (the source field can contain non-serializable data such as Callables).
- update(value, source=None)#
Create a new setting object with updated value and source.
- property parent_name#
Parent name of the parameter of
self
.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'frozen': True, 'ser_json_inf_nan': 'constants', 'validate_assignment': True, 'validate_default': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context, /)#
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self (BaseModel) – The BaseModel instance.
context (Any) – The context.
- Return type:
None
- property parent_label#
Parent label of the parameter of
self
.
- static diff_sets(first, second)#
Return a one-sided difference between two sets of Settings, prioritising values in first.
- Parameters:
- Returns:
A new set of Settings whose parameters are only found in first, and Settings in first whose values differ from their counterparts in second.
- Return type:
- create_element_parameter_for(indices)#
Utility for creating an element-wise parameter for a single value in a collection valued parameter.
- Parameters:
indices (int | list[int]) – The indices in the collection for which to create the element-wise parameter.
- Returns:
The element-wise parameter.
- Raises:
ValueError – If
self
is not collection-valued.- Return type: