Skip to content

Conversation

SwayamInSync
Copy link
Member

Copilot Summary

This pull request adds support for the spacing function for the QuadPrecision dtype, aligning its behavior with NumPy conventions and providing comprehensive tests. The changes implement the core logic for spacing in both quad and long double precision, register the new ufunc with NumPy, update documentation, and introduce a thorough test suite to verify correctness for edge cases and typical values.

QuadPrecision spacing function implementation

  • Added quad_spacing and ld_spacing functions to compute the spacing between a value and its next representable value, handling NaN and infinity per NumPy conventions and preserving the sign of the input. (quaddtype/numpy_quaddtype/src/ops.hpp) [1] [2]

NumPy ufunc integration

  • Registered the new spacing ufunc for both quad and long double types, making it available as np.spacing for QuadPrecision arrays. (quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp)

Documentation update

  • Updated the release tracker to mark spacing as implemented and tested for both quad and long double dtypes. (quaddtype/release_tracker.md)

Test suite for spacing

  • Added a comprehensive TestSpacing class with parameterized tests covering NaN/infinity, sign preservation, zero, one, negative one, magnitude, subnormal range, and array inputs, ensuring correctness and alignment with NumPy's behavior. (quaddtype/tests/test_quaddtype.py)

Copy link
Contributor

@juntyr juntyr left a comment

Choose a reason for hiding this comment

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

LGTM

@SwayamInSync
Copy link
Member Author

cool taking this in!

@SwayamInSync SwayamInSync merged commit 59cf5e5 into numpy:main Oct 21, 2025
10 checks passed
@juntyr juntyr mentioned this pull request Oct 22, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants