Skip to content

Conversation

@SwayamInSync
Copy link
Member

Copilot Summary

This pull request adds support for converting degrees to radians for quad-precision types by implementing the radians and deg2rad universal functions (ufuncs) in the codebase. It includes both the implementation of these functions for quad and long double types, their registration with NumPy, updates to the release tracker, and comprehensive tests to ensure correctness.

New ufunc implementations and registration

  • Added quad_radians and ld_radians functions to compute radians from degrees for quad-precision (Sleef_quad) and long double types, respectively, in ops.hpp. [1] [2]
  • Registered the new radians and deg2rad ufuncs in the NumPy interface initialization, making them available as universal functions for quad-precision arrays.

Documentation and tracking

  • Updated release_tracker.md to mark radians and deg2rad as implemented and tested for quad-precision.

Testing

  • Added thorough parameterized tests for both radians and deg2rad ufuncs, covering a variety of input cases including standard angles, negative values, infinities, NaNs, and edge cases.

@SwayamInSync
Copy link
Member Author

Both ufunc equivalent

quad_radians(const Sleef_quad *op)
{
// radians = degrees * π / 180
static const Sleef_quad one_eighty = Sleef_strtoq("180.0", NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using string parsing here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Easy and accurate, sometimes conversion from int or float gives precision errors (although here it shouldn't technically)

We can also go with qutil, but it seems overkill

@SwayamInSync
Copy link
Member Author

Taking this in!

@SwayamInSync SwayamInSync merged commit 120f01f into numpy:main Oct 18, 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