bundles / scipy 1.18.0 / scipy / spatial / _qhull / tsearch
cython_function_or_method
scipy.spatial._qhull:tsearch
Signature
def tsearch(tri, xi)Summary
Find simplices containing the given points. This function does the same thing as Delaunay.find_simplex.
Extended Summary
Parameters
tri: DelaunayInfoDelaunay triangulation
xi: ndarray of double, shape (..., ndim)Points to locate
Returns
i: ndarray of int, same shape as `xi`Indices of simplices containing each point. Points outside the triangulation get the value -1.
Notes
Array API Standard Support
tsearch is not in-scope for support of Python Array API Standard compatible backends other than NumPy.
See dev-arrayapi for more information.
Examples
import numpy as np import matplotlib.pyplot as plt from scipy.spatial import Delaunay, delaunay_plot_2d, tsearch rng = np.random.default_rng()✓
pts = rng.random((20, 2)) tri = Delaunay(pts) _ = delaunay_plot_2d(tri)✓
loc = rng.uniform(0.2, 0.8, (5, 2)) s = tsearch(tri, loc)✓
plt.triplot(pts[:, 0], pts[:, 1], tri.simplices[s], 'b-', mask=s==-1) plt.scatter(loc[:, 0], loc[:, 1], c='r', marker='x')✗
<matplotlib.collections.PathCollection object at 0x7fa8fc21a350>
plt.show()
✓
See also
Aliases
scipy.spatial.tsearch