-
-
Notifications
You must be signed in to change notification settings - Fork 13
FEAT: frexp ufunc implementation
#200
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
base: main
Are you sure you want to change the base?
Conversation
|
I expected it to fail on s390x but it passed that and failed on windows :) |
|
These test failures are pretty weird. Is this is expected? @seberg are we testing this properly in numpy? Details```self = <test_quaddtype.TestFrexp object at 0x00000292F997C290>, x_val = 'inf'
E AssertionError: Exponent mismatch with NumPy for frexp(inf): 0 != -1 |
|
You should compare the C standard for this type of thing, e.g. here
(similar for inf). So yes, seems fine, since I doubt that there is reason to normalize it beyond what the C standard says. |
|
Ah yes sorry, that make sense |
| return 0; | ||
| } | ||
|
|
||
| // Frexp-specific resolver: QuadPrecDType -> (QuadPrecDType, int32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it work this time with int32 when we needed intp for the other direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The python takes input as PyArray_longtype but sleef functions take int32 as input. And during the input we have to copy the bytes from big to small that causes platform issues.
In the output numpy keeps it int32 so there is no misalignedness.
Copilot Summary
This pull request adds full support for the
frexpfunction for quad-precision types in the NumPy extension, including backend implementation, ufunc integration, and comprehensive tests. The changes ensure thatfrexpbehaves consistently with NumPy's standard types, correctly handling edge cases such as zero, infinity, and NaN.Backend and API implementation:
quad_frexpandld_frexpfunctions toops.hpp, implementing correct mantissa and exponent extraction for quad-precision and long double, including handling of NaN, zero, and infinity inputs.frexp_op_quad_defandfrexp_op_longdouble_deffor backend selection of frexp operations.NumPy ufunc integration:
unary_ops.cpp, and registered the new ufunc for quad-precision types. [1] [2]Testing and documentation:
TestFrexpclass totest_quaddtype.py, covering a wide range of inputs and edge cases, and verifying consistency with NumPy's float64 results.release_tracker.mdto markfrexpas fully supported for quad-precision types.Other improvements:
binary_ops.cppfor clarity regarding binary ufuncs with two outputs.