cubie.batchsolving.solveresult
Structures used for returning results from the batch solver.
The SolveSpec
class stores the configuration of a solver run while
the SolveResult
class aggregates output arrays and related metadata.
Classes
|
Aggregates output arrays and related metadata for a solver run. |
|
Container describing a solver run. |
- class cubie.batchsolving.solveresult.SolveResult(time_domain_array: ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, summaries_array: ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, time: ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, time_domain_legend: dict[int, str] | None = NOTHING, summaries_legend: dict[int, str] | None = NOTHING, solve_settings: SolveSpec | None = None, singlevar_summary_legend: dict[int, str] | None = NOTHING, active_outputs: ActiveOutputs | None = NOTHING, stride_order: tuple[str, ...] | list[str] = ('time', 'run', 'variable'))[source]
Bases:
object
Aggregates output arrays and related metadata for a solver run.
- Parameters:
time_domain_array (Optional[NDArray]) – NumPy array containing time-domain results.
summaries_array (Optional[NDArray]) – NumPy array containing summary results.
time (Optional[NDArray]) – NumPy array containing time values.
time_domain_legend (Optional[dict[int, str]]) – Legend mapping time-domain indices to labels.
summaries_legend (Optional[dict[int, str]]) – Legend mapping summary indices to labels.
solve_settings (Optional[SolveSpec]) – Solver run configuration.
_singlevar_summary_legend (Optional[dict[int, str]]) – Legend mapping summary offset indices to labels.
_active_outputs (Optional[ActiveOutputs]) – Active outputs flags.
_stride_order (tuple[str, ...]) – Tuple specifying the order of variables in the host arrays..
- property active_outputs
Get flags indicating which device arrays are active.
- Returns:
Object storing active output flags.
- Return type:
- property as_numpy: dict[str, ndarray[Any, dtype[_ScalarType_co]] | None]
Return the results as copies of NumPy arrays.
- property as_numpy_per_summary: dict[str, ndarray[Any, dtype[_ScalarType_co]] | None]
Return the results as separate NumPy arrays per summary type.
- property as_pandas
Convert the results to Pandas DataFrames.
- Returns:
Dictionary with keys ‘time_domain’ and ‘summaries’ containing the corresponding DataFrames.
- Return type:
- Raises:
ImportError – If the pandas package is not available.
- static cleave_time(state: ndarray[Any, dtype[_ScalarType_co]] | FakeCUDAArray | None, time_saved: bool = False, stride_order: list[str] | None = None) tuple[ndarray[Any, dtype[_ScalarType_co]] | None, ndarray[Any, dtype[_ScalarType_co]]] [source]
Remove time from the state array if saved.
- Parameters:
- Returns:
Tuple containing the time array (or None) and the state array with time removed.
- Return type:
tuple[Optional[NDArray], NDArray]
- static combine_summaries_array(state_summaries, observable_summaries, summarise_states, summarise_observables) ndarray [source]
Combine state and observable summary arrays into a single array.
- Parameters:
- Returns:
Combined summary array.
- Return type:
np.ndarray
- static combine_time_domain_arrays(state, observables, state_active=True, observables_active=True) ndarray[Any, dtype[_ScalarType_co]] [source]
Combine state and observable arrays into a single time-domain array.
- Parameters:
- Returns:
Combined array along the last axis or a copy of the active array.
- Return type:
NDArray
- classmethod from_solver(solver: Solver | BatchSolverKernel, results_type: str = 'full') SolveResult | dict[str, Any] [source]
Create a
SolveResult
from a solver instance.- Parameters:
solver (Solver or BatchSolverKernel) – Object providing access to output arrays and metadata.
results_type ({'full', 'numpy', 'numpy_per_summary', 'pandas'}, optional) – Format of the returned results. Default
'full'
.
- Returns:
SolveResult
whenresults_type
is'full'
; otherwise a dictionary containing the requested representation of the data.- Return type:
SolveResult or dict
- property per_summary_arrays: dict[str, ndarray[Any, dtype[_ScalarType_co]]]
Split summaries_array into separate arrays keyed by summary type.
- static summary_legend_from_solver(solver: Solver) dict[int, str] [source]
Generate a summary legend from the solver instance.
- class cubie.batchsolving.solveresult.SolveSpec(dt_min: float, dt_max: float, dt_save: float, dt_summarise: float, atol: float, rtol: float, duration: float, warmup: float, algorithm: str, saved_states: List[str] | None, saved_observables: List[str] | None, summarised_states: List[str] | None, summarised_observables: List[str] | None, output_types: List[str] | None, precision: type)[source]
Bases:
object
Container describing a solver run.
- dt_min, dt_max
Minimum and maximum time step sizes.
- Type:
- atol, rtol
Absolute and relative error tolerances.
- Type:
- duration, warmup
Total integration time and initial warm-up period.
- Type:
- summarised_states, summarised_observables
Labels of variables for which summaries were computed.