State Diagnostics¶
state_diagnostics
¶
Opt-in checks of states at requested output times.
These diagnostics do not inspect internal RK stages, rejected attempts or unobserved substeps, and do not project or clamp the numerical solution.
OutputStateCheckConfig(nonnegative_indices=None, monotone_indices=(), negative_tolerance=0.0, monotone_tolerance=0.0)
dataclass
¶
Components and tolerances for checks at requested output times.
Attributes:
| Name | Type | Description |
|---|---|---|
nonnegative_indices |
tuple[int, ...] | None
|
State components expected to be nonnegative;
|
monotone_indices |
tuple[int, ...]
|
Components expected to be nondecreasing, such as cumulative counters. Empty disables increment checks. |
negative_tolerance |
float
|
A value below minus this absolute tolerance flags an output. This changes the diagnostic threshold, not the state. |
monotone_tolerance |
float
|
An increment below minus this absolute tolerance flags an output interval. It is not scaled by interval duration. |
__post_init__()
¶
Detach selectors and validate finite nonnegative tolerances.
Raises:
| Type | Description |
|---|---|
TypeError
|
If a selector or tolerance has the wrong type. |
ValueError
|
If a selector or tolerance is invalid. |
Source code in src/op_engine/state_diagnostics.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
OutputStateDiagnostics
¶
Bases: NamedTuple
Per-subgroup/field-cell checks over the requested output grid.
Arrays retain every state axis except the state-component axis. Counts count outputs or intervals with at least one flagged component, not the number of components. Values and flags stay in the input namespace.
Attributes:
| Name | Type | Description |
|---|---|---|
n_outputs |
int
|
Number of inspected outputs, including the initial state. |
complete |
bool
|
Whether every requested output was inspected. |
min_state |
Array
|
Minimum selected nonnegative-state value across outputs. NaNs propagate; inspect nonfinite counts too. |
n_negative_outputs |
Array
|
Outputs with any selected state below tolerance. |
n_nonfinite_outputs |
Array
|
Outputs with any nonfinite state component,
including components outside |
min_increment |
Array | None
|
Minimum increment of the selected monotone components,
or |
n_decreasing_intervals |
Array | None
|
Output intervals with any selected decreasing
component, or |
valid
property
¶
Return native flags for complete, finite, unflagged output records.
diagnose_trajectory(trajectory, config=None)
¶
Check an output trajectory without modifying it or extracting host scalars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory
|
Array
|
Array shaped |
required |
config
|
OutputStateCheckConfig | None
|
Component selectors and absolute tolerances. |
None
|
Returns:
| Type | Description |
|---|---|
OutputStateDiagnostics
|
Diagnostics for the complete supplied trajectory. |
OutputStateDiagnostics
|
these recorded outputs, not intermediate-step positivity or accuracy. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If config has the wrong type. |
ValueError
|
If the trajectory shape or selectors are invalid. |
Examples:
>>> import numpy as np
>>> path = np.array([[[1.0, 1.0]], [[0.9, -1.0]], [[0.81, 1.0]]])
>>> result = diagnose_trajectory(path)
>>> result.n_negative_outputs.tolist()
[0, 1]
>>> result.valid.tolist()
[True, False]
Source code in src/op_engine/state_diagnostics.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |