You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#289 put the rtol/atol check into one function, values_within_tolerance in app/context/tolerance.py. The way a tolerance is chosen is still spread out:
Two sources of truth.EvaluationParameters.rtol/atol and parsing_parameters["rtol"/"atol"]. _tolerances in physical_quantity/graphs/match.py reads one and checks the other.
"Not set" and 0 look the same.rtol: 0 can't switch off the implicit significant-figures tolerance for physical quantities: 1.04 m vs 1.0 m is graded correct with rtol: 0.
The implicit tolerance applies only to physical quantities.1.04 m vs 1.0 m passes, but symbolic 1.04 vs 1.0 fails.
The sig-fig formula is duplicated, in the app and in packages expression_parsing/numbers.py (compute_relative_tolerance_from_significant_decimals).
Loose floats are passed through evaluation.py (_apply_tolerance_aliases, _apply_precision_parameters, _build_parameters) and match.py (_tolerances, _within_tolerance).
Proposed solution
A frozen Tolerance dataclass, built once in _build_parameters and passed to both contexts:
@dataclass(frozen=True)classTolerance:
rtol: float|None=None# None = not setatol: float|None=Nonesource: str="default"# "params", "sig_figs", "decimal_places", "implicit"defcontains(self, res, ans, unit_factor=1) ->bool: ...
None means unset, so rtol: 0 really means exact.
Decide whether the implicit sig-fig tolerance applies to symbolic answers too, or to neither context.
Use the package's sig-fig helper and remove the app copy.
contains replaces values_within_tolerance, and does the unit scaling now in _within_tolerance.
Alternatives considered
Keep the floats and add a sentinel for "unset". That is smaller, but it leaves points 1, 3 and 5 as they are.
Another case for this design, from #285: ordered comparison criteria on physical quantities (<, >, <=, >=) ignore rtol/atol. For example, 1.0 m vs 1.01 m with criteria: "response >= answer" and rtol: 0.05 is graded false. The Tolerance abstraction should define what a tolerance means for an inequality as well as for equality.
Activity
m-messer commentedon Oct 30, 2026
Another case for this design, from #285: ordered comparison criteria on physical quantities (
<,>,<=,>=) ignorertol/atol. For example,1.0 mvs1.01 mwithcriteria: "response >= answer"andrtol: 0.05is graded false. TheToleranceabstraction should define what a tolerance means for an inequality as well as for equality.🤖 Generated with Claude Code