Thanks to visit codestin.com
Credit goes to github.com

Skip to content

isnan, isposinf and isneginf do not accept fractions.Fraction #15517

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

Open
francois-durand opened this issue Feb 5, 2020 · 2 comments
Open

isnan, isposinf and isneginf do not accept fractions.Fraction #15517

francois-durand opened this issue Feb 5, 2020 · 2 comments
Labels
33 - Question Question about NumPy usage or development component: numpy.ufunc

Comments

@francois-durand
Copy link

The functions isnan, isposinf and isneginf do not accept a fraction as an argument. Note that, however, math.nan accepts a fraction (but the math module has the drawback of not having the equivalent of isposinf and isneginf).

Reproducing code example:

import numpy as np
from fractions import Fraction
test = np.isnan(Fraction(1, 2))

Error message:

TypeError                                 Traceback (most recent call last)
<ipython-input-1-bead9135402d> in <module>
      1 import numpy as np
      2 from fractions import Fraction
----> 3 np.isnan(Fraction(1, 2))

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Numpy/Python version information:

1.16.4 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]

@rossbar rossbar added component: numpy.ufunc 33 - Question Question about NumPy usage or development labels Jul 17, 2020
@rossbar
Copy link
Contributor

rossbar commented Jul 17, 2020

Related discussion in #12988 and #16377, particularly this comment which gets at the larger issue of why no object loops are defined for these functions.

@francois-durand
Copy link
Author

Thanks for the links!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
33 - Question Question about NumPy usage or development component: numpy.ufunc
Projects
None yet
Development

No branches or pull requests

2 participants