Skip to content

BUG: Loss of precision in longdouble min #20872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Developer-Ecosystem-Engineering
Copy link
Contributor

Generic reuse in the latest changes around min works unless the macro is redefined for SIMD.

This change avoids scalar_min_f for generic comparisons (as it can be redefined) and defines is separately as scalar_min

This should resolve #20863

Generic reuse in the latest changes around `min` works unless the macro is redefined for SIMD.

This change avoids `scalar_min_f` for generic comparisons (as it can be redefined) and defines is separately as `scalar_min`
@seberg
Copy link
Member

seberg commented Jan 21, 2022

Thanks! Could you add a test that confirms full precision is preserved here? It would also be nice to "fuzz" it a bit around stranger cases (maybe array size and inclusion of inf – or also NaN for fmin). (Hypothesis could be an option, but it is probably unwieldy or at least needs getting used to.)

We really need to have a tests that are capable of catching this type of precision loss.

Adding tests like suggested in numpy#20863
@Developer-Ecosystem-Engineering
Copy link
Contributor Author

We've added some tests based on the comments in #20863

Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

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

Thanks. Could be nice to parametrize this more, but the whole file doesn't parametrize much, so it seems OK.

@seberg seberg merged commit 49c560c into numpy:main Feb 1, 2022
melissawm pushed a commit to melissawm/numpy that referenced this pull request Apr 12, 2022
* BUG: Loss of precision in longdouble min

Generic reuse in the latest changes around `min` works unless the macro is redefined for SIMD.

This change avoids `scalar_min_f` for generic comparisons (as it can be redefined) and defines is separately as `scalar_min`

* Add tests as requested

Adding tests like suggested in numpy#20863

* MAINT: Use `np.longdouble` rather than float128 for min/max tests

Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
seberg added a commit to seberg/numpy that referenced this pull request Apr 24, 2022
* BUG: Loss of precision in longdouble min

Generic reuse in the latest changes around `min` works unless the macro is redefined for SIMD.

This change avoids `scalar_min_f` for generic comparisons (as it can be redefined) and defines is separately as `scalar_min`

* Add tests as requested

Adding tests like suggested in numpy#20863

* MAINT: Use `np.longdouble` rather than float128 for min/max tests

Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: loss of precision in longdouble min (nightly build)
2 participants