SystemValues
- class cubie.odesystems.SystemValues(values_dict: Mapping[str, float] | Sequence[str] | None, precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], defaults: Mapping[str, float] | Sequence[str] | None = None, name: str | None = None, **kwargs: float)[source]
Bases:
objectManage keyed parameter values and their packed array representation.
- Parameters:
values_dict (dict[str, float]) – Dictionary defining parameter values. Lists of parameter names are expanded to a dictionary with
0.0defaults.precision (type[numpy.float16] | type[numpy.float32] | type[numpy.float64] | numpy.dtype[numpy.float16] | numpy.dtype[numpy.float32] | numpy.dtype[numpy.float64]) – Precision factory applied when creating the packed values array.
defaults – Optional dictionary supplying baseline parameter values.
name (str | None) – Display label used in
reproutput.**kwargs – Individual parameter overrides applied after
defaultsandvalues_dict.
Notes
Dictionary-style and array-style indexing both operate on the packed
values_arrayand backingvalues_dict.- __init__(values_dict: Mapping[str, float] | Sequence[str] | None, precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], defaults: Mapping[str, float] | Sequence[str] | None = None, name: str | None = None, **kwargs: float) None[source]
Initialise the packed values dictionary and array.
- Parameters:
values_dict – Full parameter dictionary or iterable of parameter names. Names are expanded to
0.0defaults before precision coercion.precision – Precision used when materialising
values_array.defaults – Baseline parameter dictionary applied before
values_dict.name – Friendly identifier displayed by
repr.**kwargs – Parameter overrides applied after
values_dict.
Notes
Keyword arguments replace identically named entries in
values_dictanddefaults.
- _convert_symbol_keys(input_dict: Any) Any[source]
Return a dictionary whose keys are converted to strings.
- Parameters:
input_dict – Dictionary potentially keyed by
sympy.Symbolobjects.- Returns:
Dictionary with symbol keys converted to strings, or the original
input_dictif it is not a dictionary.- Return type:
Any
- get_index_of_key(parameter_key: str, silent: bool = False) int[source]
Return the array index associated with a parameter name.
- Parameters:
parameter_key – Parameter name to locate within
indices_dict.silent – When
Truemissing keys do not trigger an exception.
- Returns:
Index of
parameter_keywithinvalues_array.- Return type:
- Raises:
- get_indices(keys_or_indices: str | int | slice | list[str | int] | ndarray, silent: bool = False) ndarray[source]
Convert parameter identifiers into packed array indices.
- Parameters:
keys_or_indices – Parameter descriptors supplied as names, indices, slices, or sequences of either.
silent – When
Truemissing keys do not trigger an exception.
- Returns:
Array of
np_int32indices targetingvalues_array.- Return type:
- Raises:
KeyError – Raised when a requested name is missing and
silentisFalse.IndexError – Raised when an index is outside the valid range.
TypeError – Raised when the provided descriptors are of unsupported or mixed types.
- get_labels(indices: list[int] | ndarray) list[str][source]
Return parameter labels for supplied indices.
- get_values(keys_or_indices: str | int | list[str | int] | ndarray) ndarray[source]
Return parameter values selected by name or index.
- Parameters:
keys_or_indices – Parameter descriptors accepted by
get_indices().- Returns:
Precision-coerced view of the requested parameter values.
- Return type:
- Raises:
KeyError – Raised when a requested name is missing.
IndexError – Raised when an index is outside the valid range.
TypeError – Raised when the descriptors are of unsupported types.
- precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64]
- set_values(keys: str | int | slice | list[str | int] | ndarray, values: float | Sequence[float] | ndarray) None[source]
Assign new values to the selected parameters.
- Parameters:
keys – Parameter descriptors accepted by
get_indices().values – Replacement values aligned with
keys.
- Raises:
ValueError – Raised when the number of values does not match
keys.
- update_from_dict(values_dict: Mapping[str, float] | None, silent: bool = False, **kwargs: float) set[str][source]
Update stored parameter values from dictionaries.
- Parameters:
values_dict – Dictionary of key-value pairs to apply.
silent – When
Truemissing keys do not trigger an exception.**kwargs – Additional key-value pairs to apply after
values_dict.
- Returns:
Keys successfully updated in the stored values.
- Return type:
- Raises: