__init__.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. """
  2. =============================================================
  3. Spatial algorithms and data structures (:mod:`scipy.spatial`)
  4. =============================================================
  5. .. currentmodule:: scipy.spatial
  6. Spatial transformations
  7. =======================
  8. These are contained in the `scipy.spatial.transform` submodule.
  9. Nearest-neighbor queries
  10. ========================
  11. .. autosummary::
  12. :toctree: generated/
  13. KDTree -- class for efficient nearest-neighbor queries
  14. cKDTree -- class for efficient nearest-neighbor queries (faster implementation)
  15. Rectangle
  16. Distance metrics
  17. ================
  18. Distance metrics are contained in the :mod:`scipy.spatial.distance` submodule.
  19. Delaunay triangulation, convex hulls, and Voronoi diagrams
  20. ==========================================================
  21. .. autosummary::
  22. :toctree: generated/
  23. Delaunay -- compute Delaunay triangulation of input points
  24. ConvexHull -- compute a convex hull for input points
  25. Voronoi -- compute a Voronoi diagram hull from input points
  26. SphericalVoronoi -- compute a Voronoi diagram from input points on the surface of a sphere
  27. HalfspaceIntersection -- compute the intersection points of input halfspaces
  28. Plotting helpers
  29. ================
  30. .. autosummary::
  31. :toctree: generated/
  32. delaunay_plot_2d -- plot 2-D triangulation
  33. convex_hull_plot_2d -- plot 2-D convex hull
  34. voronoi_plot_2d -- plot 2-D Voronoi diagram
  35. .. seealso:: :ref:`Tutorial <qhulltutorial>`
  36. Simplex representation
  37. ======================
  38. The simplices (triangles, tetrahedra, etc.) appearing in the Delaunay
  39. tessellation (N-D simplices), convex hull facets, and Voronoi ridges
  40. (N-1-D simplices) are represented in the following scheme::
  41. tess = Delaunay(points)
  42. hull = ConvexHull(points)
  43. voro = Voronoi(points)
  44. # coordinates of the jth vertex of the ith simplex
  45. tess.points[tess.simplices[i, j], :] # tessellation element
  46. hull.points[hull.simplices[i, j], :] # convex hull facet
  47. voro.vertices[voro.ridge_vertices[i, j], :] # ridge between Voronoi cells
  48. For Delaunay triangulations and convex hulls, the neighborhood
  49. structure of the simplices satisfies the condition:
  50. ``tess.neighbors[i,j]`` is the neighboring simplex of the ith
  51. simplex, opposite to the ``j``-vertex. It is -1 in case of no neighbor.
  52. Convex hull facets also define a hyperplane equation::
  53. (hull.equations[i,:-1] * coord).sum() + hull.equations[i,-1] == 0
  54. Similar hyperplane equations for the Delaunay triangulation correspond
  55. to the convex hull facets on the corresponding N+1-D
  56. paraboloid.
  57. The Delaunay triangulation objects offer a method for locating the
  58. simplex containing a given point, and barycentric coordinate
  59. computations.
  60. Functions
  61. ---------
  62. .. autosummary::
  63. :toctree: generated/
  64. tsearch
  65. distance_matrix
  66. minkowski_distance
  67. minkowski_distance_p
  68. procrustes
  69. geometric_slerp
  70. Warnings / Errors used in :mod:`scipy.spatial`
  71. ----------------------------------------------
  72. .. autosummary::
  73. :toctree: generated/
  74. QhullError
  75. """
  76. from ._kdtree import *
  77. from ._ckdtree import *
  78. from ._qhull import *
  79. from ._spherical_voronoi import SphericalVoronoi
  80. from ._plotutils import *
  81. from ._procrustes import procrustes
  82. from ._geometric_slerp import geometric_slerp
  83. # Deprecated namespaces, to be removed in v2.0.0
  84. from . import ckdtree, kdtree, qhull
  85. __all__ = [s for s in dir() if not s.startswith('_')]
  86. from . import distance, transform
  87. __all__ += ['distance', 'transform']
  88. from scipy._lib._testutils import PytestTester
  89. test = PytestTester(__name__)
  90. del PytestTester