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

1""" 

2============================================================= 

3Spatial algorithms and data structures (:mod:`scipy.spatial`) 

4============================================================= 

5 

6.. currentmodule:: scipy.spatial 

7 

8.. toctree:: 

9 :hidden: 

10 

11 spatial.distance 

12 

13Spatial transformations 

14======================= 

15 

16These are contained in the `scipy.spatial.transform` submodule. 

17 

18Nearest-neighbor queries 

19======================== 

20.. autosummary:: 

21 :toctree: generated/ 

22 

23 KDTree -- class for efficient nearest-neighbor queries 

24 cKDTree -- class for efficient nearest-neighbor queries (faster implementation) 

25 Rectangle 

26 

27Distance metrics 

28================ 

29 

30Distance metrics are contained in the :mod:`scipy.spatial.distance` submodule. 

31 

32Delaunay triangulation, convex hulls, and Voronoi diagrams 

33========================================================== 

34 

35.. autosummary:: 

36 :toctree: generated/ 

37 

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 

43 

44Plotting helpers 

45================ 

46 

47.. autosummary:: 

48 :toctree: generated/ 

49 

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 

53 

54.. seealso:: :ref:`Tutorial <qhulltutorial>` 

55 

56 

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:: 

62 

63 tess = Delaunay(points) 

64 hull = ConvexHull(points) 

65 voro = Voronoi(points) 

66 

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 

71 

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. 

76 

77Convex hull facets also define a hyperplane equation:: 

78 

79 (hull.equations[i,:-1] * coord).sum() + hull.equations[i,-1] == 0 

80 

81Similar hyperplane equations for the Delaunay triangulation correspond 

82to the convex hull facets on the corresponding N+1-D 

83paraboloid. 

84 

85The Delaunay triangulation objects offer a method for locating the 

86simplex containing a given point, and barycentric coordinate 

87computations. 

88 

89Functions 

90--------- 

91 

92.. autosummary:: 

93 :toctree: generated/ 

94 

95 tsearch 

96 distance_matrix 

97 minkowski_distance 

98 minkowski_distance_p 

99 procrustes 

100 geometric_slerp 

101 

102Warnings / Errors used in :mod:`scipy.spatial` 

103---------------------------------------------- 

104.. autosummary:: 

105 :toctree: generated/ 

106 

107 QhullError 

108""" 

109 

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 

117 

118# Deprecated namespaces, to be removed in v2.0.0 

119from . import ckdtree, kdtree, qhull 

120 

121__all__ = [s for s in dir() if not s.startswith('_')] 

122 

123from . import distance, transform 

124 

125__all__ += ['distance', 'transform'] 

126 

127from scipy._lib._testutils import PytestTester 

128test = PytestTester(__name__) 

129del PytestTester