0

I have had a big problem using scipy.spatial.Delaunay function.

I initialize a variable named tri as it follows:

tri = Delaunay(ApsArray, incremental=True)

This code works perfectly, but since I have to use this triangulation in a for loop, I want to copy tri in another variable named triTemp (as a temporal variable).

I searched in python documentation and I found in the copy module, deepcopy, which permits me to copy tri in another site in memory pointed by triTemp:

triTemp = deepcopy(tri)

It works!, but when I try to add a new point to triTemp, this error appears:

    Traceback (most recent call last):
  File "C:\Users\user\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-77-2f5ca634bc26>", line 1, in <module>
    tri.add_points([[0.2,0.3]])
  File "qhull.pyx", line 1544, in scipy.spatial.qhull._QhullUser.add_points (scipy\spatial\qhull.c:13938)
  File "qhull.pyx", line 446, in scipy.spatial.qhull._Qhull.add_points (scipy\spatial\qhull.c:4954)
TypeError: 'NoneType' object is not subscriptable

I have thought that the problem is with the parameter incremental because triTemp, is simply a copy in memory of tri, but my problem is that I don't know how to change this parameter without initializing triTemp again.

I want to use a copy, and not to calculate the triangulation again, because I think that it is more efficient, so if someone knows a method to reach this objective, please tell me.

Thanks to all, and sorry for the bad English!

JLD
  • 89
  • 5

1 Answers1

1

It's currently (Scipy 0.15.1) not possible to copy Delaunay structures when in the incremental mode, because the incremental state of the triangulation is stored internally in Qhull.

If you only need some of the attributes e.g. simplices etc. you could only copy them.

pv.
  • 33,875
  • 8
  • 55
  • 49