Setting#

Module: exa.common.data.parameter

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.

Attributes

element_indices

Element-wise indices of the parameter in self.

label

Label used as pretty identifier for display purposes, same as label of parameter.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name

Name used as identifier, same as name of parameter.

parent_label

Parent label of the parameter of self.

parent_name

Parent name of the parameter of self.

source

Return the source for this Setting's value.

unit

SI unit of the value, if applicable, same as unit of parameter.

parameter

The parameter this Setting represents.

value

Data value attached to the parameter, or None to indicate no value.

read_only

Indicates if the attribute is read-only.

path

Path in the settings tree (starting from the root SettingNode) for this setting.

Methods

create_element_parameter_for

Utility for creating an element-wise parameter for a single value in a collection valued parameter.

diff_sets

Return a one-sided difference between two sets of Settings, prioritising values in first.

fast_construct

High-performance constructor that bypasses Pydantic validation.

get_by_name

merge

remove_by_name

replace

sweep

Create a Sweep object that represents a 1d scan of this setting over the given values.

update

Create a new setting object with updated value and source.

validate_parameter_value_after

with_path_name

Copy of self with the parameter name replaced by the path name.

Parameters:
parameter: Parameter#

The parameter this Setting represents.

value: SettingValue#

Data value attached to the parameter, or None to indicate no value.

read_only: bool#

Indicates if the attribute is read-only.

path: str#

Path in the settings tree (starting from the root SettingNode) for this setting.

classmethod fast_construct(parameter, value, read_only=False, path='', source=None)#

High-performance constructor that bypasses Pydantic validation.

Parameters:
Return type:

Self

update(value, source=None)#

Create a new setting object with updated value and source.

Parameters:
  • value (Annotated[bool | str | int | float | complex | ndarray, PlainValidator(func=~exa.common.data.value.validate_value, json_schema_input_type=~typing.Any), PlainSerializer(func=~exa.common.data.value.serialize_value, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={'type': 'any'}, mode=None)] | list | None) – New value for the setting.

  • source (None | BaseModel | dict[str, Any]) – New source for the setting.

Returns:

Copy of self with modified properties.

Return type:

Setting

property name#

Name used as identifier, same as name of parameter.

model_config = {'extra': 'ignore', 'frozen': True, 'ser_json_inf_nan': 'constants', 'validate_assignment': True, 'validate_default': False}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property parent_name#

Parent name of the parameter of self.

property label#

Label used as pretty identifier for display purposes, same as label of parameter.

property parent_label#

Parent label of the parameter of self.

property unit#

SI unit of the value, if applicable, same as unit of parameter.

property element_indices: int | list[int] | None#

Element-wise indices of the parameter in self.

property source: None | BaseModel | dict[str, Any]#

Return the source for this Setting’s value.

static diff_sets(first, second)#

Return a one-sided difference between two sets of Settings, prioritising values in first.

Parameters:
  • first (set[Setting]) – Set whose values will be in the resulting diff.

  • second (set[Setting]) – Set that is compared to first.

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:

set[Setting]

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:

Parameter

with_path_name()#

Copy of self with the parameter name replaced by the path name.

Return type:

Setting

sweep(values)#

Create a Sweep object that represents a 1d scan of this setting over the given values.

Parameters:

values (Annotated[list[Any] | ndarray, PlainValidator(func=~exa.common.control.sweep.sweep_values.validate_sweep_values, json_schema_input_type=~typing.Any), PlainSerializer(func=~exa.common.control.sweep.sweep_values.serialize_sweep_values, return_type=PydanticUndefined, when_used=always), WithJsonSchema(json_schema={'type': 'any'}, mode=None)]) – Sweep values.

Returns:

The Sweep object.

Return type:

Sweep

Inheritance

Inheritance diagram of exa.common.data.parameter.Setting