SourcedValue#
- class impacthpc.src.core.SourcedValue(name: str, value: Quantity | str, min: Quantity | str | None = None, max: Quantity | str | None = None, source: str = 'No source available', standard_deviation: Quantity | str | None = None, warnings: List[str] = [], explaination: str | None = None, ontology: Ontology | None = None, important: bool = False)#
Bases:
ReplicableValue
Subclass of
ReplicableValue
representing a leaf of the tree, as opposed toOperation
, which represents the composed nodes of a tree.In addition to the attributes of ReplicableValue, Operations have an operator and operands and can represent infix operations (like a + b, where the
+
operator is between the two operands) or prefix operations (like ln(a), where the operator is a function name before the operands).Methods Summary
from_config
(name, configEntry)Create a SourcedValue from an entry of
impacthpc.src.core.config.config
Methods Documentation
- static from_config(name: str, configEntry: dict[str, Any]) SourcedValue #
Create a SourcedValue from an entry of
impacthpc.src.core.config.config
Example use :
SourcedValue.from_config("lifetime", config["default_values_ram"]["lifetime"])
- _as_formula() str #
Returns a string representing the formula this ReplicableValue represents.
For SourcedValue, returns the
SourcedValue.name
of the Sourcedvalue or a string representation of its value if name is None.
- _explain_rec(formatter: ~impacthpc.src.core.formatters.Formatter[~typing.Any, T] = <impacthpc.src.core.formatters.TextFormatter object>, recursion_level: int = 0, already_seen_values: set[int] = {}) T #
Provides an explanation of the current object using the specified formatter. Calls the
Formatter.format_sourced_value()
offormatter
and return its results.- Parameters:
formatter (Formatter[T], optional) – The formatter used to format the explanation. Defaults to
TextFormatter
.recursion_level (int, optional) – The current recursion depth, used to control nested explanations . Defaults to 0.
- Returns:
the resutl returned by
Formatter.format_sourced_value()
- Return type:
T
- static from_argument(name: str, argument: ReplicableValue | str | int | float) ReplicableValue #
- static from_argument(name: str, argument: ReplicableValue | str | int | float | None) ReplicableValue | None
Creates a
ReplicableValue
fromargument
if it is not already one.If
argument
is aReplicableValue
, it is returned as is. Otherwise, a newSourcedValue
is created with the namename
, the valueargument
, and the source"Argument"
. Ifargument
is None, returns None.- Parameters:
name (str) – The name of the
SourcedValue
created ifargument
is not aReplicableValue
.argument (ReplicableValue | str | int | float) – If it’s a
ReplicableValue
, it is returned as is. If it’s a string, aSourcedValue
is created with this string as the value. If it is a number, it is converted into a string (with no unit) and aSourcedValue
is created.
- Returns:
The resulting
ReplicableValue
.- Return type: