I built an application using the Delaunay triangulation from Scypi. In order to validate it, I want to do a Hold-One-Out test, which means that the code snippet mentioned below gets called a lot of times (~1e9). Thus, I want to make it as fast as possible.
Here is the minimum working example I want to speed up:
from scipy.spatial import Delaunay as Delaunay
import numpy as np
import time
n_pts = 100 # around 1e9 in the real application
pts = np.random.random((n_pts, 2))
t = time.time()
for i in range(n_pts):
delaunay = Delaunay(pts[np.arange(n_pts)!=i])
simplex = delaunay.find_simplex(pts[i])
print(time.time()-t)
Most of the time is used up by the find_simplex method, around 200ms of 300ms on my machine. Is there any way to speed it up? I already took a look at the qhull_options in the Delaunay constructor, however I had no success there.
Please note that I cannot change the overall structure as the "real" program works just fine and this computation is only done for validation. Thanks a lot!