hpcflow.app.ValuePerturbation#

class hpcflow.app.ValuePerturbation(_workflow=None, _element_set=None, _schema_input=None, _value=None, _value_group_idx=None, name='', path=None, multiplicative_factor=1, additive_factor=0)#

Bases: ValuePerturbation

A perturbation applied to a value.

Methods

from_json_like

Make an instance of this class from JSON (or YAML) data.

from_spec

Construct an instance from a specification dictionary.

make_persistent

Save value to a persistent workflow.

to_dict

Serialize this object as a dictionary.

to_json_like

Serialize this object as an object structure that can be trivially converted to JSON.

Attributes

additive_factor

The additive factor to apply.

multiplicative_factor

The multiplicative factor to apply.

name

The name of this perturbation.

normalised_path

The normalised path, if known.

path

The path to the value(s) to perturb.

value

The value itself.

workflow

The workflow containing this input value.

Parameters:
  • _workflow (Workflow | None) –

  • _element_set (ElementSet | None) –

  • _schema_input (SchemaInput | None) –

  • _value (Any | None) –

  • _value_group_idx (int | list[int] | None) –

  • name (str) –

  • path (Sequence[str | int | float] | None) –

  • multiplicative_factor (Numeric | None) –

  • additive_factor (Numeric | None) –

additive_factor: Numeric | None = 0#

The additive factor to apply.

classmethod from_json_like(json_like, shared_data=None)#

Make an instance of this class from JSON (or YAML) data.

Parameters:
  • json_like (str | Mapping[str, JSONed] | Sequence[Mapping[str, JSONed]] | None) – The data to deserialise.

  • shared_data (Mapping[str, ObjectList[JSONable]] | None) – Shared context data.

Return type:

The deserialised object.

classmethod from_spec(spec)#

Construct an instance from a specification dictionary.

make_persistent(workflow, source)#

Save value to a persistent workflow.

Returns:

  • str – Normalised path for this task input.

  • list[int | list[int]] – The index of the parameter data Zarr group where the data is stored.

  • bool – Whether this is newly persistent.

Parameters:
Return type:

tuple[str, list[int | list[int]], bool]

multiplicative_factor: Numeric | None = 1#

The multiplicative factor to apply.

name: str = ''#

The name of this perturbation.

property normalised_path: str#

The normalised path, if known.

path: Sequence[str | int | float] | None = None#

The path to the value(s) to perturb.

to_dict()#

Serialize this object as a dictionary.

Return type:

dict[str, Any]

to_json_like(dct=None, shared_data=None, exclude=(), path=None)#

Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.

Parameters:
  • dct (dict[str, JSONable] | None) –

  • shared_data (_JSONDeserState) –

  • exclude (Container[str | None]) –

  • path (list | None) –

Return type:

tuple[JSONDocument, _JSONDeserState]

property value: Any#

The value itself.

property workflow: Workflow | None#

The workflow containing this input value.