cubie.outputhandling.output_config
Output configuration management system for flexible, user-controlled output selection.
This module provides configuration classes for managing output settings in CUDA batch solvers, including validation of indices and output types, and automatic configuration from user-specified parameters.
Classes
|
Compile-time flags for output functionality. |
|
Configuration class for output handling with validation. |
- class cubie.outputhandling.output_config.OutputCompileFlags(save_state: bool = False, save_observables: bool = False, summarise: bool = False, summarise_observables: bool = False, summarise_state: bool = False)[source]
Bases:
object
Compile-time flags for output functionality.
This class holds boolean flags that determine which output features should be compiled into CUDA kernels for optimal performance.
- class cubie.outputhandling.output_config.OutputConfig(max_states: int, max_observables: int, saved_state_indices: List | ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, saved_observable_indices: List | ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, summarised_state_indices: List | ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, summarised_observable_indices: List | ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, output_types: List[str] = NOTHING)[source]
Bases:
object
Configuration class for output handling with validation.
This class manages output configuration settings including which variables to save, which to summarize, and various validation logic to ensure proper configuration. It handles the conversion between user-friendly output type specifications and internal boolean flags.
- Parameters:
_max_states (int) – Maximum number of state variables in the system.
_max_observables (int) – Maximum number of observable variables in the system.
_saved_state_indices (list or NDArray, optional) – Indices of state variables to save. Defaults to empty list.
_saved_observable_indices (list or NDArray, optional) – Indices of observable variables to save. Defaults to empty list.
_summarised_state_indices (list or NDArray, optional) – Indices of state variables to summarize. Defaults to empty list.
_summarised_observable_indices (list or NDArray, optional) – Indices of observable variables to summarize. Defaults to empty list.
_output_types (list[str], optional) – List of requested output types. Defaults to empty list.
Notes
Uses private attributes with property accessors to handle circular dependencies when setting indices and output flags. This design allows for proper validation while maintaining a clean public interface.
The class automatically validates that: - At least one output type is requested - All indices are within valid ranges - No duplicate indices are specified
- _check_for_no_outputs()[source]
Ensure at least one output type is requested.
- Raises:
ValueError – If no output types are enabled.
- _check_saved_indices()[source]
Convert saved indices to numpy arrays and set defaults if empty.
Notes
If index arrays are empty, creates arrays containing all possible indices for the respective variable types.
- _check_summarised_indices()[source]
Set summarised indices to saved indices if not provided.
Notes
If summarised indices are empty, defaults them to the corresponding saved indices arrays.
- _validate_index_arrays()[source]
Validate that all index arrays are within bounds and contain no duplicates.
Notes
Called post-init to allow None arrays to be replaced with default arrays before validation.
- property compile_flags: OutputCompileFlags
Get compile flags for this configuration.
- Returns:
Flags indicating which output features should be compiled.
- Return type:
- classmethod from_loop_settings(output_types: List[str], saved_state_indices=None, saved_observable_indices=None, summarised_state_indices=None, summarised_observable_indices=None, max_states: int = 0, max_observables: int = 0) OutputConfig [source]
Create configuration from integrator-compatible specifications.
- Parameters:
output_types (list[str]) – Output types from [“state”, “observables”, “time”] plus summary metrics like [“max”, “peaks”, “mean”, “rms”, “min”].
saved_state_indices (array-like, optional) – Indices of states to save in time-domain output.
saved_observable_indices (array-like, optional) – Indices of observables to save in time-domain output.
summarised_state_indices (array-like, optional) – Indices of states for summary calculations. If None, defaults to saved_state_indices.
summarised_observable_indices (array-like, optional) – Indices of observables for summary calculations. If None, defaults to saved_observable_indices.
max_states (int, default 0) – Total number of state variables in the system.
max_observables (int, default 0) – Total number of observable variables in the system.
- Returns:
Configured output configuration object.
- Return type:
Notes
This class method provides a convenient interface for creating OutputConfig objects from the parameter format used by integrator classes. It handles None values appropriately by converting them to empty arrays.
- property max_observables
Get the maximum number of observables.
- Returns:
Maximum number of observable variables.
- Return type:
- property max_states
Get the maximum number of states.
- Returns:
Maximum number of state variables.
- Return type:
- property n_saved_observables: int
Get number of observables that will be saved.
- Returns:
Number of observable variables to save in time-domain output.
- Return type:
- property n_saved_states: int
Get number of states that will be saved.
- Returns:
Number of state variables to save in time-domain output.
- Return type:
Notes
Returns the length of saved_state_indices when save_state is True, otherwise 0.
- property n_summarised_observables: int
Get number of observables that will be summarised.
- Returns:
Number of observable variables for summary calculations.
- Return type:
- property n_summarised_states: int
Get number of states that will be summarised.
- Returns:
Number of state variables for summary calculations.
- Return type:
Notes
Returns the length of summarised_state_indices when save_summaries is active, otherwise 0.
- property observable_summaries_buffer_height: int
Calculate total buffer height for observable summaries.
- Returns:
Total buffer height for all observable summary calculations.
- Return type:
- property observable_summaries_output_height: int
Calculate total output height for observable summaries.
- Returns:
Total output height for all observable summary results.
- Return type:
- property save_observables
Check if observable saving is enabled and has valid indices.
- Returns:
True if observable saving is enabled and indices are available.
- Return type:
- property save_state: bool
Check if state saving is enabled and has valid indices.
- Returns:
True if state saving is enabled and indices are available.
- Return type:
- property save_summaries: bool
Check if any summary calculations are needed.
- Returns:
True if any summary types are configured.
- Return type:
- property save_time
Check if time saving is enabled.
- Returns:
True if time values should be saved.
- Return type:
- property saved_observable_indices
Get indices of observables to save.
- Returns:
Array of observable indices, empty if observable saving is disabled.
- Return type:
np.ndarray
- property saved_state_indices
Get indices of states to save.
- Returns:
Array of state indices, empty if state saving is disabled.
- Return type:
np.ndarray
- property state_summaries_buffer_height: int
Calculate total buffer height for state summaries.
- Returns:
Total buffer height for all state summary calculations.
- Return type:
- property state_summaries_output_height: int
Calculate total output height for state summaries.
- Returns:
Total output height for all state summary results.
- Return type:
- property summaries_buffer_height_per_var: int
Calculate buffer size per variable for summary calculations.
- Returns:
Buffer height required per variable for summary metrics.
- Return type:
- property summaries_output_height_per_var: int
Calculate output array height per variable for summaries.
- Returns:
Output height required per variable for summary results.
- Return type:
- property summarise_observables: bool
Check if observable variables will be summarised.
- Returns:
True if summaries are enabled and observable indices are available.
- Return type:
- property summarise_state: bool
Check if state variables will be summarised.
- Returns:
True if summaries are enabled and state indices are available.
- Return type:
- property summarised_observable_indices
Get indices of observables to summarise.
- Returns:
Array of observable indices for summary calculations.
- Return type:
np.ndarray
- property summarised_state_indices
Get indices of states to summarise.
- Returns:
Array of state indices for summary calculations.
- Return type:
np.ndarray
- property summary_legend_per_variable
Get mapping of summary types to indices per variable.
- property summary_parameters
Get parameters for summary metrics.
- Returns:
Parameters required by the summary metrics system.
- Return type:
- property summary_types
Get the configured summary types.
- property total_summary_buffer_size: int
Calculate total size of all summary buffers.
- Returns:
Combined size of state and observable summary buffers.
- Return type:
- cubie.outputhandling.output_config._indices_validator(array, max_index)[source]
Validate that indices are valid numpy arrays within bounds.
- Parameters:
array (np.ndarray or None) – Array of indices to validate.
max_index (int) – Maximum allowed index value (exclusive).
- Raises:
TypeError – If array is not a numpy array of integers.
ValueError – If indices are out of bounds or contain duplicates.