InputParameterQuantity
- class pydsol.core.parameters.InputParameterQuantity(key: str, name: str, default_value: Quantity, display_priority: float, *, parent: InputParameterMap | None = None, description: str | None = None, read_only: bool = False, min_si: float = -inf, max_si: float = inf, format_str: str = '%.2f')[source]
Bases:
InputParameter
InputParameterQuantity defines an input parameter that can contain a quantity. For example, a Length, Speed or Duration can be entered with the corresponding unit. Limits for lowest values and highest allowed values (in the SI or base unit) can be provided for error checking, e.g., to indicate that a value should be positive.
The InputParameterQuantity has all attributes of the InputParameter. The _value attribute is of the type Quantity. It also has the following extra attributes:
- Attributes:
_min_si (float) – The lowest value (inclusive) that can be entered for this parameter. It is stored in the SI unit or base unit.
_max_si (float) – The highest value (inclusive) that can be entered for this parameter. It is stored in the SI unit or base unit.
_format (str) – The formatting string that is used in the user interface and when printing the parameter, e.g. to limit the number of decimals, to indicate the + or - sign, etc.
- __init__(key: str, name: str, default_value: Quantity, display_priority: float, *, parent: InputParameterMap | None = None, description: str | None = None, read_only: bool = False, min_si: float = -inf, max_si: float = inf, format_str: str = '%.2f')[source]
Create a new InputParameterQuantity that can contain an Quantity input value for the simulation model. Examples of quantities are Length, Frequency, Duration, etc.
- Parameters:
key (str) – The key of the parameter that can be a part of the dot-notation to uniquely identify the model parameter. The key does not contain the name of the parent, and should not contain any periods. It should also be unique within its node of the input parameter tree. The key is set at time of construction and it is immutable.
name (str) – Concise description of the input parameter, which can be used in a GUI to identify the parameter to the user.
default_value (Quantity) – The default (initial) value of the parameter.
display_priority (Union[int, float]) – A number indicating the order of display of the parameter in the parent parameter map. Floats are allowed to make it easy to insert an extra parameter between parameters that have already been allocated subsequent integer values.
parent (InputParameterMap (optional)) – The parent map in which the parameter can be retrieved using its key. Typically, only the root InputParameterMap has no parent, and all other parameters have an InputParameterMap as parent.
description (str (optional)) – A description or explanation of the InputParameter. For instance, an indication of the bounds or the type. This value is purely there for the user interface.
read_only (bool (optional)) – Whether a user is prohibited from changing the value of the parameter or not (default false, so the parameter can be changed).
min_si (float (optional)) – The lowest value (inclusive) that can be entered for this parameter, specified in SI units or base units.
max_value (float (optional)) – The highest value (inclusive) that can be entered for this parameter, specified in SI units or base units.
format_str (str (optional)) – The formatting string that is used in the user interface and when printing the parameter, e.g. to limit the number of decimals, to indicate the + or - sign, etc. The format string is used for the numeric part only. The unit is added after the value, followed by a space.
- Raises:
TypeError – when key is not a string
ValueError – when key is an empty string, or key contains a period
ValueError – when key is not unique in the parent InputParameterMap
TypeError – when name is not a string
ValueError – when name is an empty string
TypeError – when display priority is not a number
TypeError – when parent is not an InputParametermap or None
TypeError – when read_only is not a bool
TypeError – when default_value is not a Quantity
TypeError – when min_si or max_si is not a number
TypeError – when format_str is not a string
ValueError – when min_value >= max_value
ValueError – when the default value, converted to SI units or base units, is not between min_si and max_si (inclusive)
- property value: Quantity
Returns the actual value of the parameter. The value is initialized with default_value and is updated based on user input or data input.
- Returns:
The actual value of the parameter.
- Return type:
- property min_si: float
Returns the defined minimum allowed value (inclusive) of the parameter. It is stored in the SI unit or base unit.
- Returns:
The minimum allowed value of the parameter in the SI or base unit.
- Return type:
float
- property max_si: float
Returns the defined maximum allowed value (inclusive) of the parameter. It is stored in the SI unit or base unit.
- Returns:
The maximum allowed value of the parameter in the SI or base unit.
- Return type:
float
- property format_str: str
Returns the defined format string of the parameter value.
- Returns:
The defined format string of the parameter value.
- Return type:
str
- property type: Type[Quantity]
Returns the Quantity type of the parameter value (Length, Mass, etc.).
- Returns:
The Quantity type of the parameter value.
- Return type:
type[Quantity]
- set_value(value: Quantity)[source]
Set (overwrite) the actual value of the parameter. Use the correct Quantity (Length, Speed, Mass, ..) for the parameter value.
- Parameters:
value (Quantity) – The new value of the parameter.
- Raises:
ValueError – if the parameter is read-only
TypeError – if the new value is not of the correct quantity type
ValueError – if the new value is not between the min and max si/base values
- property default_value: object
Returns the default (initial) value of the parameter. The actual return type will be defined in subclasses of InputParameter. The default value is immutable.
- Returns:
The default (initial) value of the parameter.
- Return type:
object
- property description: str
Returns a description or explanation of the InputParameter. For instance, an indication of the bounds or the type. This value is purely there for the user interface.
- Returns:
A description or explanation of the InputParameter.
- Return type:
str
- property display_priority: float
Return the number indicating the order of display of the parameter in the parent parameter map. Floats make it easy to insert an extra parameter between parameters that have already been allocated subsequent integer values.
- Returns:
The number indicating the order of display of the parameter in the parent parameter map.
- Return type:
float
- extended_key()
Return the extended key of this InputParameter including parents with a dot-notation. The name of this parameter is the last entry in the dot notation.
- Returns:
The extended key of this InputParameter including parents with a dot-notation.
- Return type:
str
- property key: str
Return the key of the parameter that can be a part of the dot-notation to uniquely identify the model parameter. The key does not contain the name of the parent. The key is set at time of construction and it is immutable.
- Returns:
The key of the parameter that can be a part of the dot-notation to uniquely identify the model parameter.
- Return type:
str
- property name: str
Returns the concise description of the input parameter, which can be used in a GUI to identify the parameter to the user.
- Returns:
The concise description of the input parameter, which can be used in a GUI to identify the parameter to the user.
- Return type:
str
- property parent: InputParameterMap
Return the parent map in which the parameter can be retrieved using its key. Typically, only the root InputParameterMap has no parent, and all other parameters have an InputParameterMap as parent.
- Returns:
the parent map in which the parameter can be retrieved using its key.
- Return type:
- property read_only: bool
Return whether a user is prohibited from changing the value of the parameter or not.
- Returns:
Whether a user is prohibited from changing the value of the parameter or not.
- Return type:
bool