You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah it is a bit clunky right now. In array-api-tests we cast 0d array floats to builtin floats, before using math.copysign(1, your_builtin_float) == 1 to see whether its positively signed or not. Maybe it's not too big of a deal to add a function for it (or possibly modifying sign), don't have a sense for that.
which brings up a question on how implementors can distinguish between -0.0 and +0.0 in their test suite.
For an implementer to test something, it isn't required to use only functions in the standard. This is checking the value of a bit, which can be done with a private function even.
Not saying that it's not a good idea to have this function - but especially given that JAX doesn't have it, it'd be nice to have a stronger reason.
I checked the SciPy code base. There's a lot of use of the C/C++ versions of signbit in compiled code, but only a couple in Python code:
Activity
honno commentedon Aug 1, 2023
Yeah it is a bit clunky right now. In
array-api-testswe cast 0d array floats to builtin floats, before usingmath.copysign(1, your_builtin_float) == 1to see whether its positively signed or not. Maybe it's not too big of a deal to add a function for it (or possibly modifyingsign), don't have a sense for that.asmeurer commentedon Aug 1, 2023
There is a proposal for copysign at #593.
rgommers commentedon Sep 6, 2023
For an implementer to test something, it isn't required to use only functions in the standard. This is checking the value of a bit, which can be done with a private function even.
Not saying that it's not a good idea to have this function - but especially given that JAX doesn't have it, it'd be nice to have a stronger reason.
I checked the SciPy code base. There's a lot of use of the C/C++ versions of
signbitin compiled code, but only a couple in Python code:Scikit-learn doesn't have any usage of
signbit, and Pandas has four instances:jakevdp commentedon Nov 13, 2023
JAX does have signbit: https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.signbit.html
rgommers commentedon Nov 13, 2023
Okay, that is two votes for adding
signbitand all libraries have it, so there are no blockers. The signature is as simple as it gets:Let's add it?
kgryte commentedon Nov 13, 2023
I can create a PR later this week.
rgommers commentedon Nov 16, 2023
PR is up for review: gh-705