TypeError:ufunc'add'不包含循环 [英] TypeError: ufunc 'add' did not contain a loop

查看:765
本文介绍了TypeError:ufunc'add'不包含循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Anaconda和gdsCAD并在正确安装所有软件包时收到错误消息. 就像这里解释的那样: http://pythonhosted.org/gdsCAD/

I use Anaconda and gdsCAD and get an error when all packages are installed correctly. Like explained here: http://pythonhosted.org/gdsCAD/

TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('S32') dtype('S32') dtype('S32')

我的导入看起来像这样(最后我导入了所有内容):

My imports look like this (In the end I imported everything):

import numpy as np
from gdsCAD import *
import matplotlib.pyplot as plt

我的示例代码如下:

something = core.Elements()
box=shapes.Box( (5,5),(1,5),0.5)
core.default_layer = 1
core.default_colors = 2
something.add(box)
something.show()

我的错误消息如下:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-2f90b960c1c1> in <module>()
 31 puffer_wafer = shapes.Circle((0.,0.), puffer_wafer_radius, puffer_line_thickness)
 32 bp.add(puffer_wafer)
---> 33 bp.show()
 34 wafer = shapes.Circle((0.,0.), wafer_radius, wafer_line_thickness)
 35 bp.add(wafer)

C:\Users\rpilz\AppData\Local\Continuum\Anaconda2\lib\site-packages\gdscad-0.4.5-py2.7.egg\gdsCAD\core.pyc in _show(self)
 80     ax.margins(0.1)
 81 
---> 82     artists=self.artist()
 83     for a in artists:
 84         a.set_transform(a.get_transform() + ax.transData)

C:\Users\rpilz\AppData\Local\Continuum\Anaconda2\lib\site-packages\gdscad-0.4.5-py2.7.egg\gdsCAD\core.pyc in artist(self, color)
952         art=[]
953         for p in self:
--> 954             art+=p.artist()
955         return art
956 

C:\Users\rpilz\AppData\Local\Continuum\Anaconda2\lib\site-packages\gdscad-0.4.5-py2.7.egg\gdsCAD\core.pyc in artist(self, color)
475         poly = lines.buffer(self.width/2.)
476 
--> 477         return [descartes.PolygonPatch(poly, lw=0, **self._layer_properties(self.layer))]
478 
479 

C:\Users\rpilz\AppData\Local\Continuum\Anaconda2\lib\site-packages\gdscad-0.4.5-py2.7.egg\gdsCAD\core.pyc in _layer_properties(layer)
103         # Default colors from previous versions
104         colors = ['k', 'r', 'g', 'b', 'c', 'm', 'y']
--> 105         colors += matplotlib.cm.gist_ncar(np.linspace(0.98, 0, 15))
106         color = colors[layer % len(colors)]
107         return {'color': color}

TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('S32') dtype('S32') dtype('S32')    

推荐答案

从图形化安装到此绘图问题,gdsCAD一直很痛苦.
此问题是由于将错误的数据类型传递给colors函数.可以通过在core.py

The gdsCAD has been a pain from shapely install to this plotting issue.
This issue is because of wrong datatype being passed to colors function. It can be solved by editing the following line in core.py

colors += matplotlib.cm.gist_ncar(np.linspace(0.98, 0, 15))

colors += list(matplotlib.cm.gist_ncar(np.linspace(0.98, 0, 15)))

如果您不知道core.py的位置.只需输入:

If you dont know where the core.py is located. Just type in:

from gdsCAD import *
core

这将为您提供core.py文件的路径.祝你好运!

This will give you the path of core.py file. Good luck !

这篇关于TypeError:ufunc'add'不包含循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆