bluemira.base.parameter_frame._parameter
Attributes
Classes
Typed dictionary for a Parameter. |
|
Holds parameter value information. |
|
Represents a parameter with physical units. |
Functions
|
Module Contents
- bluemira.base.parameter_frame._parameter.type_fail(exc, memo)
- Raises:
TypeError – Wrong type
Notes
typeguard by default raises a TypeCheckError may want to have a custom checker in future
- bluemira.base.parameter_frame._parameter.ParameterValueType
- class bluemira.base.parameter_frame._parameter.ParamDictT
Bases:
TypedDictTyped dictionary for a Parameter.
- name: str
- value: ParameterValueType
- unit: str
- source: str
- description: str
- long_name: str
- class bluemira.base.parameter_frame._parameter.ParameterValue
Bases:
Generic[ParameterValueType]Holds parameter value information.
- value: ParameterValueType
- source: str
- class bluemira.base.parameter_frame._parameter.Parameter(name: str, value: ParameterValueType, unit: str = '', source: str = '', description: str = '', long_name: str = '', _value_types: tuple[type, Ellipsis] | None = None)
Bases:
Generic[ParameterValueType]Represents a parameter with physical units.
- Parameters:
name (str) – The name of the parameter.
value (ParameterValueType) – The parameter’s value.
unit (str) – The parameter’s unit.
source (str) – The origin of the parameter’s value.
description (str) – A description of the parameter.
long_name (str) – A longer name for the parameter.
_value_types (tuple[type, Ellipsis] | None)
- _name
- _value
- _unit
- _source = ''
- _description = ''
- _long_name = ''
- _history: list[ParameterValue[ParameterValueType]] = []
- static _type_check(name: str, value: ParameterValueType, value_types: tuple[type, Ellipsis] | None) ParameterValueType
- Parameters:
name (str)
value (ParameterValueType)
value_types (tuple[type, Ellipsis] | None)
- Return type:
ParameterValueType
- __repr__() str
String repr of class instance.
- Returns:
The string representation of the class instance.
- Return type:
str
- __eq__(o: object, /) bool
Check if this parameter is equal to another.
Parameters are equal if their names and values (with matching units) are equal.
- Returns:
True if the parameters are equal, False otherwise.
- Parameters:
o (object)
- Return type:
bool
- __hash__() int
- Return type:
int
- history() list[ParameterValue[ParameterValueType]]
Return the history of this parameter’s value.
- Returns:
A list of ParameterValue objects, the history of this parameter’s value.
- Return type:
list[ParameterValue[ParameterValueType]]
- set_value(new_value: ParameterValueType, source: str = '')
Set the parameter’s value and update the source.
- Parameters:
new_value (ParameterValueType)
source (str)
- to_dict(*, use_last: bool = False) dict[str, Any]
Serialise the parameter to a dictionary.
- Returns:
A dictionary representation of the parameter.
- Parameters:
use_last (bool)
- Return type:
dict[str, Any]
- property name: str
Return the name of the parameter.
- Return type:
str
- property value: ParameterValueType
Return the current value of the parameter.
- Return type:
ParameterValueType
- value_as(unit: str | pint.Unit) ParameterValueType | None
Return the current value in a given unit
- Parameters:
unit (str | pint.Unit) – The unit to convert the value to
- Returns:
The value in the new unit
- Raises:
ValueError – Unit conversion failed
TypeError – If the wrong unit type is passed in
- Return type:
ParameterValueType | None
Notes
If the current value of the parameter is None the function checks for a valid unit conversion
- property unit: str
Return the physical unit of the parameter.
- Return type:
str
- property source: str
Return the source that last set the value of this parameter.
- Return type:
str
- property long_name: str
Return a long name for this parameter.
- Return type:
str
- property description: str
Return a description for the parameter.
- Return type:
str
- _add_history_record()
- property _last_param: ParameterValue
- Return type:
- property last: ParameterValue
Get the last value that isnt None from a parameter
- Raises:
ValueError – All values in history are None
- Return type: