hpcflow.sdk.core.parameters.MultiPathSequence#
- class hpcflow.sdk.core.parameters.MultiPathSequence(paths, values, nesting_order=None, label=None, value_class_method=None)#
Bases:
_BaseSequence
A sequence of values to be distributed across one or more paths.
Notes
This is useful when we would like to generate values for multiple input paths that have some interdependency, or when they must be generate together in one go.
- Parameters:
paths (Sequence[str]) – The paths to this multi-path sequence.
values (NDArray | Sequence[Sequence] | None) – The values in this multi-path sequence.
nesting_order (int) – A nesting order for this multi-path sequence. Can be used to compose sequences together.
label (str) – A label for this multi-path sequence.
value_class_method (str) – Name of a method used to generate multi-path sequence values. Not normally used directly.
Methods
Make an instance of this class from JSON (or YAML) data.
Generate values from SciPy's latin hypercube sampler:
scipy.stats.qmc.LatinHypercube
.Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Attributes
The range indices (start and stop) to the parent element set's sequences list that correspond to the `ValueSequence`s generated by this multi-path sequence, if this object is bound to a parent element set.
The child value sequences, one for each path.
- classmethod from_json_like(json_like, shared_data=None)#
Make an instance of this class from JSON (or YAML) data.
- Parameters:
json_like – The data to deserialise.
shared_data – Shared context data.
- Return type:
The deserialised object.
- classmethod from_latin_hypercube(paths, num_samples, *, bounds=None, scramble=True, strength=1, optimization=None, rng=None, nesting_order=None, label=None)#
Generate values from SciPy’s latin hypercube sampler:
scipy.stats.qmc.LatinHypercube
.- Parameters:
paths (Sequence[str]) – List of dot-delimited paths within the parameter’s nested data structure for which ‘value’ should be set.
num_samples (int) – Number of random hypercube samples to take.
bounds (dict[str, dict[str, str | Sequence[float]]] | None, optional) – Bounds dictionary structure which takes a path as a key and returns another dictionary which takes scaling and extent as keys. extent defines the width of the parameter space, and scaling defines whether to take logarithmically spaced samples (“log”) or not (“linear”). By default, linear scaling and an extent between 0 and 1 is used.
scramble (bool, optional) – See scipy.stats.qmc.LatinHypercube, by default True
strength (int, optional) – See ‘scipy.stats.qmc.LatinHypercube’, by default 1
optimization (Literal["random, optional) – See ‘scipy.stats.qmc.LatinHypercube’, by default None
rng (_type_, optional) – See ‘scipy.stats.qmc.LatinHypercube’, by default None
- Returns:
Array of hypercube samples.
- Return type:
NDArray
- property sequence_indices: Sequence[int] | None#
The range indices (start and stop) to the parent element set’s sequences list that correspond to the `ValueSequence`s generated by this multi-path sequence, if this object is bound to a parent element set.
- property sequences: Sequence[ValueSequence]#
The child value sequences, one for each path.
- 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.