SystemInterface
- class cubie.batchsolving.SystemInterface.SystemInterface(parameters: SystemValues, states: SystemValues, observables: SystemValues)[source]
Bases:
objectConvenience accessor for system values.
- Parameters:
parameters – System parameter values object.
states – System state values object.
observables – System observable values object.
Notes
Acts as a wrapper for
BaseODEcomponents so that higher-level utilities can access names, indices, and default values from an underlying system. Adds some layers of convenience for resolving user-requested variable lists to indices for use by CUDA functions.The variable resolution methods (
resolve_variable_labels(),merge_variable_inputs(),convert_variable_labels()) consolidate all label-to-index conversion logic. These methods interpret input values as follows:Nonemeans “use all” (default behavior)[]or empty array means “explicitly no variables”When both labels and indices are provided, their union is used
- classmethod from_system(system: BaseODE) SystemInterface[source]
Create a SystemInterface from a system model.
- Parameters:
system – The system model to create an interface for.
- Returns:
A new instance wrapping the system’s values.
- Return type:
- get_labels(values_object: SystemValues, indices: ndarray) List[str][source]
Return labels corresponding to the provided indices.
- merge_variable_inputs(var_labels: List[str] | None, state_indices: List[int] | ndarray | None, observable_indices: List[int] | ndarray | None) Tuple[ndarray, ndarray][source]
Merge label-based selections with index-based selections.
- Parameters:
var_labels – Variable names to resolve. None means “not provided”.
state_indices – Direct state index selection. None means “not provided”.
observable_indices – Direct observable index selection. None means “not provided”.
- Returns:
Final (state_indices, observable_indices) arrays.
- Return type:
Tuple[np.ndarray, np.ndarray]
Notes
When all three inputs are None, returns full range arrays (all states, all observables). When any input is explicitly empty ([] or empty array), that emptiness is preserved. Union of resolved labels and provided indices is returned.
- merge_variable_labels_and_idxs(output_settings: Dict[str, Any]) None[source]
Convert variable label settings to index arrays in-place.
- Parameters:
output_settings – Settings dict containing
save_variables,summarise_variables, and their index counterparts. Modified in-place.- Returns:
Modifies output_settings in-place.
- Return type:
None
- Raises:
ValueError – If any variable labels are not found in states or observables.
Notes
Pops
save_variablesandsummarise_variablesfrom the dict and replaces index parameters with final resolved arrays. For summarised indices, defaults to saved indices when both labels and indices are None.
- observable_indices(keys_or_indices: List[str | int] | str | int, silent: bool = False) ndarray[source]
Convert observable labels or indices to a numeric array.
- Parameters:
keys_or_indices – Observable names, indices, or a mix of both.
Nonereturns all observable indices.silent – If
True, suppresses warnings for unrecognized keys or indices.
- Returns:
Array of integer indices corresponding to the provided identifiers.
- Return type:
ndarray
- observable_labels(indices: ndarray | None = None) List[str][source]
Return observable labels corresponding to the provided indices.
- parameter_indices(keys_or_indices: List[str | int] | str | int, silent: bool = False) ndarray[source]
Convert parameter labels or indices to a numeric array.
- Parameters:
keys_or_indices – Parameter names, indices, or a mix of both.
silent – If
True, suppresses warnings for unrecognized keys or indices.
- Returns:
Array of integer indices corresponding to the provided identifiers.
- Return type:
ndarray
- parameter_labels(indices: ndarray | None = None) List[str][source]
Return parameter labels corresponding to the provided indices.
- resolve_variable_labels(labels: List[str] | None, silent: bool = False) Tuple[ndarray | None, ndarray | None][source]
Resolve variable labels to separate state and observable indices.
- Parameters:
labels – Variable names that may be states or observables. If
None, returns(None, None)to signal “use defaults”. If empty list, returns empty arrays for both.silent – If
True, suppresses errors for unrecognized labels.
- Returns:
Tuple of (state_indices, observable_indices). Returns
(None, None)when labels is None.- Return type:
Tuple[Optional[np.ndarray], Optional[np.ndarray]]
- Raises:
ValueError – If any label is not found in states or observables and silent is False.
- state_indices(keys_or_indices: List[str | int] | str | int | None = None, silent: bool = False) ndarray[source]
Convert state labels or indices to a numeric array.
- Parameters:
keys_or_indices – State names, indices, or a mix of both.
Nonereturns all state indices.silent – If
True, suppresses warnings for unrecognized keys or indices.
- Returns:
Array of integer indices corresponding to the provided identifiers.
- Return type:
ndarray
- state_labels(indices: ndarray | None = None) List[str][source]
Return state labels corresponding to the provided indices.
- update(updates: Dict[str, Any] | None = None, silent: bool = False, **kwargs) Set[str] | None[source]
Update default parameter or state values.
- Parameters:
updates – Mapping of label to new value. If
None, only keyword arguments are used for updates.silent – If
True, suppressesKeyErrorfor unrecognized update keys.**kwargs – Additional keyword arguments merged with
updates. Each key-value pair represents a label-value mapping for updating system values.
- Returns:
Set of recognized update keys that were successfully applied. Returns None if no updates were provided.
- Return type:
- Raises:
KeyError – If
silentis False and unrecognized update keys are provided.
Notes
The method attempts to update both parameters and states. Updates are applied to whichever
SystemValuesobject recognizes each key.