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
Can't plot point size when using sympy return types: AttributeError: 'Integer' object has no attribute 'sqrt' #13106
This happens because some sympy functions return a "One" or "Integer" object. So it is not matplotlib's fault that they do this instead of a normal int, but it took me a while to figure out this error. Including a cast to float would fix it.
More confusingly, somehow it looks like the matplotlib code thinks that "np" is the number I passed as the point size, since it is checking whether that has a "sqrt" attribute.
Actually, that's rather an issue between numpy and sympy. numpy does not consider a sympy Integer to be a number.
>>> 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'
The message itself comes from numpy, which apparently tries to call a sqrt method on unknown objects.
I don't think we should work around this in matplotlib (or even just try to make a better error message). That's something to discuss between sympy and numpy.
Activity
timhoffm commentedon Jan 5, 2019
Actually, that's rather an issue between numpy and sympy. numpy does not consider a sympy Integer to be a number.
The message itself comes from numpy, which apparently tries to call a
sqrtmethod on unknown objects.I don't think we should work around this in matplotlib (or even just try to make a better error message). That's something to discuss between sympy and numpy.