cubie.batchsolving.SystemInterface

Convenience interface for accessing system values.

This module provides the SystemInterface class which wraps SystemValues instances for parameters, states, and observables. It exposes helper methods for converting between user-facing labels/indices and internal representations.

Classes

SystemInterface

Convenient accessor for system values with label/index conversion methods.

Notes

The SystemInterface allows updating default state or parameter values without navigating the full system hierarchy, providing a simplified interface for common operations.

Classes

SystemInterface(parameters, states, observables)

Convenient accessor for system values.

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

Bases: object

Convenient accessor for system values.

This class wraps SystemValues instances for parameters, states, and observables and provides methods for converting between user-facing labels/indices and internal representations.

Parameters:
  • parameters (SystemValues) – System parameter values object.

  • states (SystemValues) – System state values object.

  • observables (SystemValues) – System observable values object.

property all_input_labels: List[str]

Get all input labels, the union of state and parameter labels.

Returns:

List containing all state labels followed by all parameter labels.

Return type:

list of str

Notes

This property provides a convenient way to access all system inputs (states and parameters) in a single list.

property all_output_labels: List[str]

Get all output labels, the union of state and observable labels.

Returns:

List containing all state labels followed by all observable labels.

Return type:

list of str

Notes

This property provides a convenient way to access all system outputs (states and observables) in a single list.

classmethod from_system(system: GenericODE) SystemInterface[source]

Create a SystemInterface from a system model.

Parameters:

system (GenericODE) – The system model to create an interface for.

Returns:

A new SystemInterface 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 (SystemValues) – The SystemValues object to retrieve labels from.

  • indices (np.ndarray) – A 1D array of integer indices.

Returns:

List of labels corresponding to the provided indices.

Return type:

list of str

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 (list of {str, int} or str or int or None, default)

  • None. – Observable names, indices, or a mix of both. Can be a single name/index or a list containing strings (observable names) and/or integers (indices). None returns all observable indices.

  • silent (bool, default False) – If True, suppresses warnings for unrecognized keys or indices.

Returns:

Array of integer indices corresponding to the provided observable names or indices. Always returns a 1D array, even for single inputs.

Return type:

np.ndarray

observable_labels(indices: ndarray | None = None) List[str][source]

Get the labels of observables corresponding to the provided indices.

Parameters:

indices (np.ndarray, optional) – A 1D array of observable indices. If None, return all observable labels.

Returns:

List of observable labels corresponding to the provided indices. If indices is None, returns all observable labels.

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 (list of {str, int} or str or int) – Parameter names, indices, or a mix of both. Can be a single name/index or a list containing strings (parameter names) and/or integers (indices).

  • silent (bool, default False) – If True, suppresses warnings for unrecognized keys or indices.

Returns:

Array of integer indices corresponding to the provided parameter names or indices. Always returns a 1D array, even for single inputs.

Return type:

np.ndarray

parameter_labels(indices: ndarray | None = None) List[str][source]

Get the labels of parameters corresponding to the provided indices.

Parameters:

indices (np.ndarray, optional) – A 1D array of parameter indices. If None, return all parameter labels.

Returns:

List of parameter labels corresponding to the provided indices. If indices is None, returns all parameter labels.

Return type:

list of str

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 (list of {str, int} or str or int or None, default)

  • None. – State names, indices, or a mix of both. Can be a single name/index or a list containing strings (state names) and/or integers (indices). None returns all state indices.

  • silent (bool, default False) – If True, suppresses warnings for unrecognized keys or indices.

Returns:

Array of integer indices corresponding to the provided state names or indices. Always returns a 1D array, even for single inputs.

Return type:

np.ndarray

state_labels(indices: ndarray | None = None) List[str][source]

Get the labels of the states corresponding to the provided indices.

Parameters:

indices (np.ndarray, optional) – A 1D array of state indices. If None, return all state labels.

Returns:

List of state labels corresponding to the provided indices. If indices is None, returns all state labels.

Return type:

list of str

update(updates: Dict[str, float] | None = None, silent: bool = False, **kwargs) set | None[source]

Update default parameter or state values.

Parameters:
  • updates (dict of str to float, optional) – Mapping of label to new value. If None, only keyword arguments are used for updates.

  • silent (bool, default False) – 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 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.