SystemInterface

class cubie.batchsolving.SystemInterface.SystemInterface(parameters: SystemValues, states: SystemValues, observables: SystemValues)[source]

Bases: object

Convenience 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 BaseODE components 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:

  • None means “use all” (default behavior)

  • [] or empty array means “explicitly no variables”

  • When both labels and indices are provided, their union is used

property all_input_labels: List[str]

List all input labels (states followed by parameters).

property all_output_labels: List[str]

List all output labels (states followed by observables).

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:

SystemInterface

get_labels(values_object: SystemValues, indices: ndarray) List[str][source]

Return labels corresponding to the provided indices.

Parameters:
  • values_object – The SystemValues object to retrieve labels from.

  • indices – A 1D array of integer indices.

Returns:

List of labels corresponding to the provided indices.

Return type:

list of str

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_variables and summarise_variables from 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. None returns 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.

Parameters:

indices – A 1D array of observable indices. If None, return all observable labels.

Returns:

List of observable labels corresponding to the provided indices.

Return type:

list of str

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.

Parameters:

indices – A 1D array of parameter indices. If None, return all parameter labels.

Returns:

List of parameter labels corresponding to the provided indices.

Return type:

list of str

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. None returns 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.

Parameters:

indices – A 1D array of state indices. If None, return all state labels.

Returns:

List of state labels corresponding to the provided indices.

Return type:

list of str

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, suppresses KeyError for 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:

set of str or None

Raises:

KeyError – If silent is False and unrecognized update keys are provided.

Notes

The method attempts to update both parameters and states. Updates are applied to whichever SystemValues object recognizes each key.