Skip to content

Conversation

@SwayamInSync
Copy link
Member

@SwayamInSync SwayamInSync commented Oct 17, 2025

Copilot Summary

This pull request adds support for the np.fabs universal function (ufunc) for the custom QuadPrecision dtype, ensuring it behaves identically to np.absolute for real numbers. The implementation includes both the underlying C++ registration and comprehensive tests for various input values. The release tracker documentation is also updated to reflect this new support.

Feature addition:

  • Added the fabs ufunc for the QuadPrecision dtype in the C++ extension by registering it in init_quad_unary_ops. This ensures that np.fabs can be used with quad-precision numbers.

Testing:

  • Introduced a new parameterized test test_fabs in test_quaddtype.py to verify the correctness of np.fabs for QuadPrecision scalars and arrays, covering positive, negative, zero, special, and small values. The test also checks that the sign of zero is positive after applying fabs.

Documentation:

  • Updated release_tracker.md to mark fabs as supported for both the ufunc and its corresponding Python API, reflecting the new implementation status.

@SwayamInSync
Copy link
Member Author

similar to absolute, just does not handle the complex types (so do we) hence registering absolute as fabs

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, with the added comment

@SwayamInSync
Copy link
Member Author

Let's take this in as well!

@SwayamInSync SwayamInSync merged commit e73f34f into numpy:main Oct 17, 2025
9 checks passed
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