Skip to content

Fixed ConstantComparator#768

Closed
volkm wants to merge 1 commit intostormchecker:masterfrom
volkm:compare
Closed

Fixed ConstantComparator#768
volkm wants to merge 1 commit intostormchecker:masterfrom
volkm:compare

Conversation

@volkm
Copy link
Contributor

@volkm volkm commented Aug 25, 2025

The ConstantComparator had two issues in my view.

Comparison with equal should take the maximum instead of the sum for relative precision. This also follows how python computes isclose.
Currently, the check 0.4 == 0.6 with relative precision 0.2 would yield true (0.2 <= 0.2*(0.4+0.6)) but should be false instead (0.2 <= 0.2* max(0.4,0.6)).

The less than comparison is also not right in my view.
Currently, the check 0.9 < 1 is false because of 0.9 < 1 - 0.2.
The proposed fix does lead to some errors though, because e.g. in the SparseMatrix a check isLess(0.1, 0) now yields true.

Should we also adapt the check in the SparseMatrix or define IsLess in a different way?

@sjunges
Copy link
Contributor

sjunges commented Aug 26, 2025

I am working on a larger overhaul of the comparator. I will include the changes you suggested here in that PR (to be uploaded soon).

@volkm
Copy link
Contributor Author

volkm commented Aug 26, 2025

Sounds good. Feel free to close this PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants