Correctness metrics from numerical evaluation. Contains error measurements comparing the solution output against a reference implementation to assess numerical accuracy. When the output contains non-finite values, ``max_absolute_error`` and ``max_relative_error`` are set to ``0.0``
| 25 | |
| 26 | |
| 27 | class Correctness(BaseModelWithDocstrings): |
| 28 | """Correctness metrics from numerical evaluation. |
| 29 | |
| 30 | Contains error measurements comparing the solution output against |
| 31 | a reference implementation to assess numerical accuracy. |
| 32 | |
| 33 | When the output contains non-finite values, ``max_absolute_error`` and |
| 34 | ``max_relative_error`` are set to ``0.0`` (since no meaningful error |
| 35 | metric can be computed) and one of ``has_nan`` / ``has_inf`` is set to |
| 36 | ``True`` to signal the reason. |
| 37 | """ |
| 38 | |
| 39 | max_relative_error: float = Field(default=0.0) |
| 40 | """Maximum relative error observed across all output elements.""" |
| 41 | max_absolute_error: float = Field(default=0.0) |
| 42 | """Maximum absolute error observed across all output elements.""" |
| 43 | has_nan: bool = Field(default=False) |
| 44 | """True when the solution or reference output contains NaN values.""" |
| 45 | has_inf: bool = Field(default=False) |
| 46 | """True when the solution or reference output contains Inf values (but no NaN).""" |
| 47 | extra: Optional[dict[str, Any]] = Field(default=None) |
| 48 | """Extra metrics for correctness evaluation.""" |
| 49 | |
| 50 | @field_validator("max_relative_error", "max_absolute_error") |
| 51 | @classmethod |
| 52 | def non_negative(cls, v: float): |
| 53 | if v < 0: |
| 54 | raise ValueError("must be non-negative") |
| 55 | return v |
| 56 | |
| 57 | |
| 58 | class Performance(BaseModelWithDocstrings): |
no outgoing calls
no test coverage detected