我遇到了mpmath的问题。我试图从文档中的示例重现一个情节。我怀疑问题是命名空间冲突,但我无法让它工作。这是我的代码和错误:
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
我已尝试以各种顺序重新排列三个导入命令,并尝试将其中一个输出,但没有成功。我正在使用Mac OSX Sierra上Anaconda python安装的Jupyter笔记本工作。我有mpmath 0.19,matplotlib 1.5.3。 当我执行“conda list”时,我找不到列出的pylab。但是,“来自pylab import *”不会引发错误。建议进行故障排除?这是包装安装的问题吗?