-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Add methods from the builtin float types to the numpy floating point types #13375
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
Comments
Cpython has |
Need to fix for all the np float types: np.float32, numpy.float16 / np.single, np.half:
|
I think we can also add |
With the merging of #19803 |
I'll take a stab at |
@ganesh-k13 You should be aware that there was a long-standing corner-case bug in the |
Thanks for the heads up @mdickinson! |
See numpy/numpy#13375. `__trunc__` is not defined for NumPy scalars other than `float64`, so we can't call `math.trunc(x)` in the CUDA simulator for NumPy scalars `x` if they are not `float64` type.
Python 3.14 also adds a |
Uh oh!
There was an error while loading. Please reload this page.
Asking for methods that exist on builtin float types but not numpy types gives:
Filtering these to the ones that are not CPython implementation details, we have:
__trunc__(self) -> int
, which will enablemath.trunc(numpy_float)
is_integer(self) -> bool
(done in ENH: Addis_integer
tonp.floating
&np.integer
#19803)as_integer_ratio(self) -> Tuple[int, int]
(done in ENH: Implementnp.floating.as_integer_ratio
#10741)hex(self) -> str
fromhex(cls: Type[FloatType], s: str) -> FloatType
For all of these, the best approach is probably to port the CPython implementations, taking care to handle the extended precision of
long double
s.Note that we get these methods for free on
np.float64
due to inheriting fromfloat
The text was updated successfully, but these errors were encountered: