SourcedValue#
- class impactshpc.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:
ReplicableValueSubclass of
ReplicableValuerepresenting 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).- source
The source of this value, for example, a quote from a scientific article.
- Type:
Methods Summary
Creates a
ReplicableValuefromargumentif it is not already one.from_config(name, configEntry)Create a SourcedValue from an entry of
impacthpc.src.core.config.configMethods Documentation
- 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
ReplicableValuefromargumentif it is not already one.If
argumentis aReplicableValue, it is returned as is. Otherwise, a newSourcedValueis created with the namename, the valueargument, and the source"Argument". Ifargumentis None, returns None.- Parameters:
name (str) – The name of the
SourcedValuecreated ifargumentis not aReplicableValue.argument (ReplicableValue | str | int | float) – If it’s a
ReplicableValue, it is returned as is. If it’s a string, aSourcedValueis created with this string as the value. If it is a number, it is converted into a string (with no unit) and aSourcedValueis created.
- Returns:
The resulting
ReplicableValue.- Return type:
- static from_config(name: str, configEntry: dict[str, Any]) SourcedValue#
Create a SourcedValue from an entry of
impacthpc.src.core.config.configExample 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.nameof the Sourcedvalue or a string representation of its value if name is None.
- _explain_rec(formatter: ~impactshpc.src.core.formatters.Formatter[~typing.Any, T] = <impactshpc.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()offormatterand return its results.- Parameters:
- 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
ReplicableValuefromargumentif it is not already one.If
argumentis aReplicableValue, it is returned as is. Otherwise, a newSourcedValueis created with the namename, the valueargument, and the source"Argument". Ifargumentis None, returns None.- Parameters:
name (str) – The name of the
SourcedValuecreated ifargumentis not aReplicableValue.argument (ReplicableValue | str | int | float) – If it’s a
ReplicableValue, it is returned as is. If it’s a string, aSourcedValueis created with this string as the value. If it is a number, it is converted into a string (with no unit) and aSourcedValueis created.
- Returns:
The resulting
ReplicableValue.- Return type:
- static from_config(name: str, configEntry: dict[str, Any]) SourcedValue
Create a SourcedValue from an entry of
impacthpc.src.core.config.configExample use :
SourcedValue.from_config("lifetime", config["default_values_ram"]["lifetime"])