2013-08-28 5 views
5

Odkurzam kod napisany kilka miesięcy temu, az jakiegoś powodu już nie działa ... W skrócie Używam obiektów scipy.interpolate.LinearNDInterpolator do interpolowania modeli i porównywania z danymi. Teraz, gdy próbuję wywołać obiekt IPO ze współrzędnymi, w którym chciałbym interpolacji, pojawia się następujący błąd:scipy.interpolate.interpnd narzeka na obiekt "Delaunay" nie ma atrybutu "simplices"

In [9]: a([[3500, 3.5, 1.5]]) 
AttributeError       Traceback (most recent call last) 
<ipython-input-9-91f2103e7a0c> in <module>() 
----> 1 a([[3500, 3.5, 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' 

Nigdy nie widziałem tego błędu przed, a kod pracował wcześniej. Czy coś po prostu zmieniło się w scipy, którego nie jestem świadomy?

Dzięki za opiekę!

+0

Czy możesz stworzyć prosty, samodzielny przykład demonstrujący problem? Którą wersję scipy używałeś wcześniej i czego teraz używasz? –

Odpowiedz

3

Chyba używasz starszej wersji biblioteki:

Biblioteka Delaunay ma dwa różne akcesorów dla simplices: "Delaunay.simplices" i "Delaunay.vertices" pokazane tutaj (najnowsze Docs): http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Delaunay.html

Z dwóch Delaunay.vertices jest oznaczonych jako "przestarzałe".

Na Ubuntu 13.04 simplices wezwanie nie istnieje jednak, ponieważ nadal korzysta scipy 0.11.0: http://docs.scipy.org/doc/scipy-0.11.0/reference/generated/scipy.spatial.Delaunay.html#scipy.spatial.Delaunay

Spróbuj z tym minimalnym przykład lub po prostu przepisać simplices zadzwonić do wierzchołków:

from __future__ import print_function 

import numpy as np 
from scipy.spatial import Delaunay 
import sys 

my_molecule = np.random.rand(400,3) #points for query 
points = np.random.rand(1000, 3) #points used for Triangulation 

diag = 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] 
Powiązane problemy