Skip to content

Conversation

mhucka
Copy link
Contributor

@mhucka mhucka commented Aug 25, 2025

Changes:

  1. isclose() now accepts relative and absolute tolerances. This allows for more precise control over the comparison, just like in NumPy.
  2. Adjusted the comparison logic. The old implementation used a single tolerance value that it scaled in a way that could produce incorrect results. The new logic uses a common formula for checking if 1 numbers are close:
    abs(a - b) <= abs_tol + rel_tol * max(abs(a), abs(b))
    
  3. Updated __eq__ in SymbolicOperator to use the tolerance values.
  4. Added a new test symbolic_operator_test.py.

Changes:

1. `isclose()` now accepts relative and absolute tolerances. This allows
   for more precise control over the comparison, just like in NumPy.

2. The comparison logic was corrected. The old implementation used a
   single tolerance value that it scaled in a way that could produce
   incorrect results. The new logic uses a common formula for checking
   if 1 numbers are close:
   ```
   abs(a - b) <= abs_tol + rel_tol * max(abs(a), abs(b))
   ```

3. Updated `__eq__` in `SymbolicOperator` to use the tolerance values.

4. Added a new test `symbolic_operator_test.py`.
@mhucka mhucka marked this pull request as ready for review August 25, 2025 21:15
@mhucka mhucka added the area/health Involves code and/or project health label Aug 25, 2025
@mpharrigan
Copy link
Collaborator

gentle ping

Per comments in PR review, this renames `rel_tol` and `abs_tol` to be
`rtol` and `atol`, respectively, as well ask keeps the previous `tol`
parameter but marks it as deprecated.
@mhucka mhucka requested a review from mpharrigan September 19, 2025 23:44
Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@mhucka mhucka added this pull request to the merge queue Sep 23, 2025
Merged via the queue into master with commit 9f3a2ee Sep 23, 2025
30 checks passed
@mhucka mhucka deleted the mh-fix-764 branch September 23, 2025 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/health Involves code and/or project health
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants