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
{{ message }}
Repository navigation
AttributeError when taking sine of huge number #13875
Fixed in #12700 to produce a better error message, now gives:
>>> np.sin(70**11)
AttributeError: 'int' object has no attribute 'sin'
The above exception was the direct cause of the following exception:
TypeError: loop of ufunc does not support argument 0 of type int which has no callable sin method
Passing a float as np.sin(70.0**11) will work fine
Maybe I'm missing something, but the "fixed" version still seems like a completely opaque error message.
Someone runs np.sin(7) and it works, and suddenly for a big number it doesn't work. Shouldn't the error message be something like Input is too large to calculate sin, use float?
Until we get rid of automatic coercion to an object array this is probably about as good as it will get. We could maybe make the error message spell out a bit more things, but we cannot just put in "input is too large" or so, at the point where the error message happens that would just be guessing. Although maybe you can suggest a wording which makes things easier.
Activity
eric-wieser commentedon Jun 30, 2019
Fixed in #12700 to produce a better error message, now gives:
Passing a float as
np.sin(70.0**11)will work finecool-RR commentedon Jun 30, 2019
Maybe I'm missing something, but the "fixed" version still seems like a completely opaque error message.
Someone runs
np.sin(7)and it works, and suddenly for a big number it doesn't work. Shouldn't the error message be something likeInput is too large to calculate sin, use float?seberg commentedon Jun 30, 2019
Until we get rid of automatic coercion to an object array this is probably about as good as it will get. We could maybe make the error message spell out a bit more things, but we cannot just put in "input is too large" or so, at the point where the error message happens that would just be guessing. Although maybe you can suggest a wording which makes things easier.
cool-RR commentedon Jun 30, 2019
Can't the error catching logic check whether this is an int which is above a certain threshold, and then use the "int is too large" message?
eric-wieser commentedon Jun 30, 2019
No, because
np.sin(np.array(1, dtype=object))has the same problem.The cause here is:
70**11is not an array, so is coerced to one70**11is too large to fit in anint64array, so anobjectarray types is chosennp.sin(object_array)is only supported if the objects within have asinmethod