Repository navigation
Handle infinite values in the C isclose() like math.isclose() - #1487
Closed
zzoraemon043 wants to merge 1 commit into
Closed
zzoraemon043 wants to merge 1 commit into
zzoraemon043 wants to merge 1 commit into
Conversation
The C helper returned True for a finite value compared to an infinite value (and for inf vs -inf), and False for two equal infinite values. Vec2.isclose() and Vec3.isclose() of the C extension inherited this.
Owner
|
In this case: NO - this is nasty but in CAD applications infinite values are not expected. EDIT: There will be no end to it if I open this Pandora’s box! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
isclose()helper inacc/vector.pyxis commented "Has to match the Python implementation!", but it skips the infinity checks ofmath.isclose(). With the C extension:inf - xisinf, andrel_tol * infis alsoinf, sodiff <= fabs(rel_tol * b)passes; for two equal infinitiesdiffisnan.Vec2behaves the same, and the Cconstruct,bezierandbsplinecode share this helper.The fix adds the two early checks from CPython's
math.isclose(): equal values are close, and an infinite value is only close to itself. Finite inputs give the same results as before.Added tests to suites 602 and 603, so they run against both implementations: the C variants fail before the fix and pass after.
pytest tests(C extension rebuilt): 8225 passed, 28 skipped.