SolveResult
- class cubie.batchsolving.solveresult.SolveResult(time_domain_array: ndarray[Any, dtype[_ScalarType_co]] = NOTHING, summaries_array: ndarray[Any, dtype[_ScalarType_co]] = NOTHING, time: ndarray[Any, dtype[_ScalarType_co]] | None = NOTHING, iteration_counters: ndarray[Any, dtype[_ScalarType_co]] = NOTHING, status_codes: ndarray[Any, dtype[_ScalarType_co]] | None = None, 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', 'variable', 'run'))[source]
Bases:
objectAggregate output arrays and related metadata for a solver run.
- Parameters:
time_domain_array (numpy.ndarray[Any, numpy.dtype[numpy._typing._array_like._ScalarType_co]]) – NumPy array containing time-domain results.
summaries_array (numpy.ndarray[Any, numpy.dtype[numpy._typing._array_like._ScalarType_co]]) – NumPy array containing summary results.
time (numpy.ndarray[Any, numpy.dtype[numpy._typing._array_like._ScalarType_co]] | None) – Optional NumPy array containing time values.
iteration_counters (numpy.ndarray[Any, numpy.dtype[numpy._typing._array_like._ScalarType_co]]) – NumPy array containing iteration counts per run.
status_codes (numpy.ndarray[Any, numpy.dtype[numpy._typing._array_like._ScalarType_co]] | None) – Optional NumPy array containing solver status codes per run (0 for success, nonzero for errors). Shape is (n_runs,) with dtype int32.
time_domain_legend (dict[int, str] | None) – Optional mapping from time-domain indices to labels.
summaries_legend (dict[int, str] | None) – Optional mapping from summary indices to labels.
solve_settings (cubie.batchsolving.solveresult.SolveSpec | None) – Optional solver run configuration.
active_outputs – Optional
ActiveOutputsinstance describing enabled arrays.stride_order – Sequence describing the order of axes in host arrays.
singlevar_summary_legend – Optional mapping from summary offsets to legend labels.
- property active_outputs: ActiveOutputs
Return the active output flags.
- 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: dict[str, pd.DataFrame]
Convert the results to pandas DataFrames.
- Returns:
Dictionary containing
time_domainandsummariesDataFrames.- Return type:
- Raises:
ImportError – Raised when pandas is not available.
Notes
Pandas is an optional dependency that is imported lazily.
- static cleave_time(state: ndarray[Any, dtype[_ScalarType_co]] | FakeCUDAArray | None, time_saved: bool = False, stride_order: Tuple[str, ...] | None = None) tuple[ndarray[Any, dtype[_ScalarType_co]] | None, ndarray[Any, dtype[_ScalarType_co]]][source]
Remove time from the state array when present.
- Parameters:
state – State array potentially containing a time column.
time_saved – Flag indicating if time is saved in the state array.
stride_order – Optional order of dimensions in the array. Defaults to
["time", "variable", "run"]whenNone.
- Returns:
Pair 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: ndarray[Any, dtype[_ScalarType_co]] | FakeCUDAArray | None, observable_summaries: ndarray[Any, dtype[_ScalarType_co]] | FakeCUDAArray | None, summarise_states: bool, summarise_observables: bool) ndarray[source]
Combine state and observable summary arrays into a single array.
- Parameters:
state_summaries – Array containing state summaries.
observable_summaries – Array containing observable summaries.
summarise_states – Flag indicating if state summaries are active.
summarise_observables – Flag indicating if observable summaries are active.
- Returns:
Combined summary array along the variable axis (axis=1).
- Return type:
ndarray
- static combine_time_domain_arrays(state: ndarray[Any, dtype[_ScalarType_co]] | FakeCUDAArray | None, observables: ndarray[Any, dtype[_ScalarType_co]] | FakeCUDAArray | None, state_active: bool = True, observables_active: bool = True) ndarray[Any, dtype[_ScalarType_co]][source]
Combine state and observable arrays into a single time-domain array.
- Parameters:
state – Array of state values.
observables – Array of observable values.
state_active – Flag indicating if state values are active.
observables_active – Flag indicating if observable values are active.
- Returns:
Combined array along the variable axis (axis=1) for 3D arrays, or a copy of the active array.
- Return type:
NDArray
- classmethod from_solver(solver: Solver | BatchSolverKernel, results_type: str = 'full', nan_error_trajectories: bool = True) SolveResult | dict[str, Any][source]
Create a
SolveResultfrom a solver instance.- Parameters:
solver – Object providing access to output arrays and metadata.
results_type – Format of the returned results. Options are
"full","numpy","numpy_per_summary",raw, and"pandas". Defaults to"full".rawshortcuts all processing and outputs numpy arrays that are a direct copy of the host, without legends or supporting information.nan_error_trajectories – When
True(default), trajectories with nonzero status codes are set to NaN. WhenFalse, all trajectories are returned with original values regardless of status. This parameter is ignored whenresults_typeis"raw".
- Returns:
SolveResultwhenresults_typeis"full"; otherwise a dictionary containing the requested representation.- Return type:
SolveResult or dict[str, Any]
- 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.