Coverage for /usr/lib/python3/dist-packages/scipy/spatial/__init__.py: 100%
14 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-14 15:55 +0200
1"""
2=============================================================
3Spatial algorithms and data structures (:mod:`scipy.spatial`)
4=============================================================
6.. currentmodule:: scipy.spatial
8.. toctree::
9 :hidden:
11 spatial.distance
13Spatial transformations
14=======================
16These are contained in the `scipy.spatial.transform` submodule.
18Nearest-neighbor queries
19========================
20.. autosummary::
21 :toctree: generated/
23 KDTree -- class for efficient nearest-neighbor queries
24 cKDTree -- class for efficient nearest-neighbor queries (faster implementation)
25 Rectangle
27Distance metrics
28================
30Distance metrics are contained in the :mod:`scipy.spatial.distance` submodule.
32Delaunay triangulation, convex hulls, and Voronoi diagrams
33==========================================================
35.. autosummary::
36 :toctree: generated/
38 Delaunay -- compute Delaunay triangulation of input points
39 ConvexHull -- compute a convex hull for input points
40 Voronoi -- compute a Voronoi diagram hull from input points
41 SphericalVoronoi -- compute a Voronoi diagram from input points on the surface of a sphere
42 HalfspaceIntersection -- compute the intersection points of input halfspaces
44Plotting helpers
45================
47.. autosummary::
48 :toctree: generated/
50 delaunay_plot_2d -- plot 2-D triangulation
51 convex_hull_plot_2d -- plot 2-D convex hull
52 voronoi_plot_2d -- plot 2-D Voronoi diagram
54.. seealso:: :ref:`Tutorial <qhulltutorial>`
57Simplex representation
58======================
59The simplices (triangles, tetrahedra, etc.) appearing in the Delaunay
60tessellation (N-D simplices), convex hull facets, and Voronoi ridges
61(N-1-D simplices) are represented in the following scheme::
63 tess = Delaunay(points)
64 hull = ConvexHull(points)
65 voro = Voronoi(points)
67 # coordinates of the jth vertex of the ith simplex
68 tess.points[tess.simplices[i, j], :] # tessellation element
69 hull.points[hull.simplices[i, j], :] # convex hull facet
70 voro.vertices[voro.ridge_vertices[i, j], :] # ridge between Voronoi cells
72For Delaunay triangulations and convex hulls, the neighborhood
73structure of the simplices satisfies the condition:
74``tess.neighbors[i,j]`` is the neighboring simplex of the ith
75simplex, opposite to the ``j``-vertex. It is -1 in case of no neighbor.
77Convex hull facets also define a hyperplane equation::
79 (hull.equations[i,:-1] * coord).sum() + hull.equations[i,-1] == 0
81Similar hyperplane equations for the Delaunay triangulation correspond
82to the convex hull facets on the corresponding N+1-D
83paraboloid.
85The Delaunay triangulation objects offer a method for locating the
86simplex containing a given point, and barycentric coordinate
87computations.
89Functions
90---------
92.. autosummary::
93 :toctree: generated/
95 tsearch
96 distance_matrix
97 minkowski_distance
98 minkowski_distance_p
99 procrustes
100 geometric_slerp
102Warnings / Errors used in :mod:`scipy.spatial`
103----------------------------------------------
104.. autosummary::
105 :toctree: generated/
107 QhullError
108"""
110from ._kdtree import *
111from ._ckdtree import *
112from ._qhull import *
113from ._spherical_voronoi import SphericalVoronoi
114from ._plotutils import *
115from ._procrustes import procrustes
116from ._geometric_slerp import geometric_slerp
118# Deprecated namespaces, to be removed in v2.0.0
119from . import ckdtree, kdtree, qhull
121__all__ = [s for s in dir() if not s.startswith('_')]
123from . import distance, transform
125__all__ += ['distance', 'transform']
127from scipy._lib._testutils import PytestTester
128test = PytestTester(__name__)
129del PytestTester