mpmath: data type not understood

295 views Asked by At

I am having an issue with mpmath. I am trying to reproduce a plot from the examples in the documentation. I suspect the issue is a namespace clash, but I can't get it to work. Here is my code and the error:

from pylab import *
from matplotlib import *
from mpmath import *

r, R = 1, 2.5
f = lambda u, v: [r*cos(u), (R+r*sin(u))*cos(v), (R+r*sin(u))*sin(v)]
splot(f, [0, 2*pi], [0, 2*pi])    

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-42-3f3bdff4f661> in <module>()
      5 r, R = 1, 2.5
      6 f = lambda u, v: [r*cos(u), (R+r*sin(u))*cos(v), (R+r*sin(u))*sin(v)]
----> 7 splot(f, [0, 2*pi], [0, 2*pi])

/Users/kevin/anaconda/lib/python2.7/site-packages/mpmath/visualization.pyc in splot(ctx, f, u, v, points, keep_aspect, wireframe, file, dpi, axes)
    227         points = [points, points]
    228     M, N = points
--> 229     u = pylab.linspace(ua, ub, M)
    230     v = pylab.linspace(va, vb, N)
    231     x, y, z = [pylab.zeros((M, N)) for i in xrange(3)]

/Users/kevin/anaconda/lib/python2.7/site-packages/numpy/core/function_base.pyc in linspace(start, stop, num, endpoint, retstep, dtype)
     91     stop = stop * 1.
     92 
---> 93     dt = result_type(start, stop, float(num))
     94     if dtype is None:
     95         dtype = dt

TypeError: data type not understood

I have tried rearranging the three import commands in various orders, and have tried leaving one out as well, without success. I am working in a Jupyter notebook from an Anaconda python installation on Mac OSX Sierra. I have mpmath 0.19, matplotlib 1.5.3. I cannot find pylab listed when I do "conda list". However, "from pylab import *" does not raise an error. Suggestions for troubleshooting? Is this an issue with package installation?

0

There are 0 answers