Variables
This module contains definitions of LUME-model variables for use with lume tools. Variables are designed as pure descriptors and thus aren't intended to hold actual values, but they can be used to validate encountered values.
For now, only scalar floating-point variables are supported.
Variable
Bases: BaseModel
, ABC
Abstract variable base class.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the variable. |
Source code in lume_model/variables.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
default_validation_config
abstractmethod
property
Determines default behavior during validation.
ScalarVariable
Bases: Variable
Variable for float values.
Attributes:
Name | Type | Description |
---|---|---|
default_value |
Optional[float]
|
Default value for the variable. Note that the LUMEBaseModel requires this for input variables, but it is optional for output variables. |
value_range |
Optional[tuple[float, float]]
|
Value range that is considered valid for the variable. If the value range is set to None, the variable is interpreted as a constant and values are validated against the default value. |
is_constant |
Optional[bool]
|
Flag indicating whether the variable is constant. |
unit |
Optional[str]
|
Unit associated with the variable. |
Source code in lume_model/variables.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
validate_value(value, config=None)
Validates the given value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The value to be validated. |
required |
config
|
ConfigEnum
|
The configuration for validation. Defaults to None. Allowed values are "none", "warn", and "error". |
None
|
Raises:
Type | Description |
---|---|
TypeError
|
If the value is not of type float. |
ValueError
|
If the value is out of the valid range or does not match the default value for constant variables. |
Source code in lume_model/variables.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|