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 to Operation, 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:

str

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"])
Parameters:
  • name (str) – the name of the SourcedValue created

  • configEntry (dict[str, Any]) – a config entry

_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() of formatter 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 from argument if it is not already one.

If argument is a ReplicableValue, it is returned as is. Otherwise, a new SourcedValue is created with the name name, the value argument, and the source "Argument". If argument is None, returns None.

Parameters:
Returns:

The resulting ReplicableValue.

Return type:

ReplicableValue

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"])
Parameters:
  • name (str) – the name of the SourcedValue created

  • configEntry (dict[str, Any]) – a config entry