python – scipy.interpolate.interpnd抱怨’Delaunay’对象没有属性’simplices’

python – scipy.interpolate.interpnd抱怨’Delaunay’对象没有属性’simplices’,第1张

概述几个月前我写的一些代码正在粉碎,并且由于某些原因它不再起作用……简而言之,我使用scipy.interpolate.LinearNDInterpolator对象来插入模型并与数据进行比较.现在,当我尝试使用我想要插值的坐标调用插值器对象时,我收到以下错误: In [9]: a([[3500, 3.5, 1.5]])AttributeError 几个月前我写的一些代码正在粉碎,并且由于某些原因它不再起作用……简而言之,我使用scipy.interpolate.linearNDInterpolator对象来插入模型并与数据进行比较.现在,当我尝试使用我想要插值的坐标调用插值器对象时,我收到以下错误:
In [9]: a([[3500,3.5,1.5]])AttributeError                            Traceback (most recent call last)<ipython-input-9-91f2103e7a0c> in <module>()----> 1 a([[3500,1.5]])/usr/lib64/python2.7/site-packages/scipy/interpolate/interpnd.so in     scipy.interpolate.interpnd.NDInterpolatorBase.__call__ (scipy/interpolate/interpnd.c:3133)()/usr/lib64/python2.7/site-packages/scipy/interpolate/interpnd.so in     scipy.interpolate.interpnd.linearNDInterpolator._evaluate_double (scipy/interpolate/interpnd.c:3954)()/usr/lib64/python2.7/site-packages/scipy/interpolate/interpnd.so in scipy.interpolate.interpnd.linearNDInterpolator._do_evaluate (scipy/interpolate/interpnd.c:4684)()AttributeError: 'delaunay' object has no attribute 'simplices'

我之前从未见过这个错误,代码以前也有用过.在我不知道的scipy中,有些东西发生了变化吗?

谢谢你的期待!

解决方法 我想你使用的是旧版本的库:

delaunay库有两个不同的simplices访问器:
“delaunay.simplices”和“delaunay.vertices”
这里显示(最新文档):http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Delaunay.html

在两个delaunay.vertices中标记为“已弃用”.

在Ubuntu 13.04上,simplices调用不存在,因为它仍然使用scipy 0.11.0:
http://docs.scipy.org/doc/scipy-0.11.0/reference/generated/scipy.spatial.Delaunay.html#scipy.spatial.Delaunay

尝试使用这个最小的例子或只是重写你的simplices调用顶点:

from __future__ import print_functionimport numpy as npfrom scipy.spatial import delaunayimport sysmy_molecule = np.random.rand(400,3) #points for querypoints = np.random.rand(1000,3)   #points used for Triangulationdiag = delaunay(points)simplices = diag.find_simplex(my_molecule)for point,simplex in zip(my_molecule,simplices):    if simplex == -1:        print ("Point not included in diag.")        continue    print ("Doing vertices call: ")    spoints = diag.vertices[simplex]    print ("Doing simplices call: ")    spoints = diag.simplices[simplex]
总结

以上是内存溢出为你收集整理的python – scipy.interpolate.interpnd抱怨’Delaunay’对象没有属性’simplices’全部内容,希望文章能够帮你解决python – scipy.interpolate.interpnd抱怨’Delaunay’对象没有属性’simplices’所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1205107.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存