OutputFunctions
- class cubie.outputhandling.OutputFunctions(n_states: int, n_observables: int, precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], output_types: list[str] = None, saved_state_indices: Sequence[int] | ArrayLike = None, saved_observable_indices: Sequence[int] | ArrayLike = None, summarised_state_indices: Sequence[int] | ArrayLike = None, summarised_observable_indices: Sequence[int] | ArrayLike = None, sample_summaries_every: float | None = None, **compile_flags: object)[source]
Bases:
CUDAFactoryFactory that compiles and caches output management functions.
- Parameters:
n_states – Maximum number of state variables in the system.
n_observables – Maximum number of observable variables in the system.
output_types – Types of output to generate. Defaults to [“state”].
saved_state_indices – Indices of state variables to save in time-domain output.
saved_observable_indices – Indices of observable variables to save in time-domain output.
summarised_state_indices – Indices of state variables to include in summary calculations.
summarised_observable_indices – Indices of observable variables to include in summary calculations.
sample_summaries_every – Time interval between summary metric samples. Used by derivative metrics to scale finite differences. Defaults to None.
precision – Numerical precision for output calculations. Defaults to np.float32.
Notes
The constructor converts the provided options into an
OutputConfiginstance and installs it as the compile settings. CUDA callables are only built once per configuration and cached bycubie.CUDAFactory.- _update(updates: Dict[str, Any], silent: bool) set[str][source]
Trim stored indices to new maxima, then apply the settings.
- Parameters:
updates – Setting names to new values; gains trimmed index arrays when
n_statesorn_observableschanges.silent – Whether
update()ignores unrecognised names.
- Returns:
Names the output settings recognised.
- Return type:
Notes
Explicit indices in the same update win over trimmed ones.
- build() OutputFunctionCache[source]
Compile output functions and calculate memory requirements.
- Returns:
Container with compiled functions that target the current configuration.
- Return type:
OutputFunctionCache
Notes
This method is invoked lazily by
cubie.CUDAFactorythe first time a compiled function is requested. The resulting cache is reused until configuration settings change.
- property compile_flags: OutputCompileFlags
Compile flags for the active configuration.
- property observable_summaries_buffer_height: int
Total height of the buffer for observable summary calculations.
- property output_array_heights: OutputArrayHeights
Output array height helper built from the active configuration.
- property saved_observable_indices: NDArray[int64]
Indices of observables saved in time-domain output.
- property saved_state_indices: NDArray[int64]
Indices of states saved in time-domain output.
- settings_keys: frozenset | None = frozenset({'afn', 'arcp', 'contract', 'ftz', 'lineinfo', 'lto', 'nsz', 'output_types', 'precision', 'reassoc', 'sample_summaries_every', 'saved_observable_indices', 'saved_state_indices', 'summarised_observable_indices', 'summarised_state_indices', 'unroll_accumulator', 'unroll_krylov_exits', 'unroll_newton_exits', 'unroll_norms', 'unroll_other_small', 'unroll_solver_element', 'unroll_stage', 'unroll_step_element'})
Loose keys the factory accepts;
Noneaccepts every field.
- property state_summaries_buffer_height: int
Total height of the buffer for state summary calculations.
- property summarised_observable_indices: NDArray[int64]
Indices of observables tracked by summary metrics.
- property summarised_state_indices: NDArray[int64]
Indices of states tracked by summary metrics.
- property summary_legend_per_variable: dict[str, int]
Mapping of summary metric names to their per-variable heights.
- property summary_unit_modifications: dict[int, str]
Mapping of summary indices to unit modification strings.