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
sqrt raises AttributeError on unexpected input #7961
>>> import numpy as np
>>> x = Integer(10)
>>> np.sqrt(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Integer' object has no attribute 'sqrt'
+1 from me on improving the error message. Raising TypeError("Object loop of ufunc {} does not support object of type {} which has no {} method") if the attribute is absent would be helpful.
I'm not sure if we should also try and check is the attribute is callable.
Perhaps chaining the exception would be useful here
Activity
charris commentedon Aug 22, 2016
Noneis treated as an object, which is why asqrtattribute is looked for. Perhaps the error/error_message can be improved.timhoffm commentedon Jan 5, 2019
Same problem with sympy integers:
Reported in matplotlib/matplotlib#13106.
A better error message would really help to find out what's going on.
eric-wieser commentedon Jan 5, 2019
+1 from me on improving the error message. Raising
TypeError("Object loop of ufunc {} does not support object of type {} which has no {} method")if the attribute is absent would be helpful.I'm not sure if we should also try and check is the attribute is callable.
Perhaps chaining the exception would be useful here
Merge pull request #12700 from mattip/gh-7961
MAINT: restore CPU dispatch wrapper and guard object ufunc fallback