package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `Voronoi
]
type t = [ `Object | `Voronoi ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : ?furthest_site:bool -> ?incremental:bool -> ?qhull_options:string -> points:[> `Ndarray ] Np.Obj.t -> unit -> t

Voronoi(points, furthest_site=False, incremental=False, qhull_options=None)

Voronoi diagrams in N dimensions.

.. versionadded:: 0.12.0

Parameters ---------- points : ndarray of floats, shape (npoints, ndim) Coordinates of points to construct a convex hull from furthest_site : bool, optional Whether to compute a furthest-site Voronoi diagram. Default: False incremental : bool, optional Allow adding new points incrementally. This takes up some additional resources. qhull_options : str, optional Additional options to pass to Qhull. See Qhull manual for details. (Default: 'Qbb Qc Qz Qx' for ndim > 4 and 'Qbb Qc Qz' otherwise. Incremental mode omits 'Qz'.)

Attributes ---------- points : ndarray of double, shape (npoints, ndim) Coordinates of input points. vertices : ndarray of double, shape (nvertices, ndim) Coordinates of the Voronoi vertices. ridge_points : ndarray of ints, shape ``(nridges, 2)`` Indices of the points between which each Voronoi ridge lies. ridge_vertices : list of list of ints, shape ``(nridges, * )`` Indices of the Voronoi vertices forming each Voronoi ridge. regions : list of list of ints, shape ``(nregions, * )`` Indices of the Voronoi vertices forming each Voronoi region. -1 indicates vertex outside the Voronoi diagram. point_region : list of ints, shape (npoints) Index of the Voronoi region for each input point. If qhull option 'Qc' was not specified, the list will contain -1 for points that are not associated with a Voronoi region. furthest_site True if this was a furthest site triangulation and False if not.

.. versionadded:: 1.4.0

Raises ------ QhullError Raised when Qhull encounters an error condition, such as geometrical degeneracy when options to resolve are not enabled. ValueError Raised if an incompatible array is given as input.

Notes ----- The Voronoi diagram is computed using the `Qhull library <http://www.qhull.org/>`__.

Examples -------- Voronoi diagram for a set of point:

>>> points = np.array([0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], ... [2, 0], [2, 1], [2, 2]) >>> from scipy.spatial import Voronoi, voronoi_plot_2d >>> vor = Voronoi(points)

Plot it:

>>> import matplotlib.pyplot as plt >>> fig = voronoi_plot_2d(vor) >>> plt.show()

The Voronoi vertices:

>>> vor.vertices array([0.5, 0.5], [0.5, 1.5], [1.5, 0.5], [1.5, 1.5])

There is a single finite Voronoi region, and four finite Voronoi ridges:

>>> vor.regions [], [-1, 0], [-1, 1], [1, -1, 0], [3, -1, 2], [-1, 3], [-1, 2], [0, 1, 3, 2], [2, -1, 0], [3, -1, 1] >>> vor.ridge_vertices [-1, 0], [-1, 0], [-1, 1], [-1, 1], [0, 1], [-1, 3], [-1, 2], [2, 3], [-1, 3], [-1, 2], [1, 3], [0, 2]

The ridges are perpendicular between lines drawn between the following input points:

>>> vor.ridge_points array([0, 3], [0, 1], [2, 5], [2, 1], [1, 4], [7, 8], [7, 6], [7, 4], [8, 5], [6, 3], [4, 5], [4, 3], dtype=int32)

val add_points : ?restart:bool -> points:[> `Ndarray ] Np.Obj.t -> [> tag ] Obj.t -> Py.Object.t

add_points(points, restart=False)

Process a set of additional new points.

Parameters ---------- points : ndarray New points to add. The dimensionality should match that of the initial points. restart : bool, optional Whether to restart processing from scratch, rather than adding points incrementally.

Raises ------ QhullError Raised when Qhull encounters an error condition, such as geometrical degeneracy when options to resolve are not enabled.

See Also -------- close

Notes ----- You need to specify ``incremental=True`` when constructing the object to be able to add points incrementally. Incremental addition of points is also not possible after `close` has been called.

val close : [> tag ] Obj.t -> Py.Object.t

close()

Finish incremental processing.

Call this to free resources taken up by Qhull, when using the incremental mode. After calling this, adding more points is no longer possible.

val points : t -> Py.Object.t

Attribute points: get value or raise Not_found if None.

val points_opt : t -> Py.Object.t option

Attribute points: get value as an option.

val vertices : t -> Py.Object.t

Attribute vertices: get value or raise Not_found if None.

val vertices_opt : t -> Py.Object.t option

Attribute vertices: get value as an option.

val ridge_points : t -> Py.Object.t

Attribute ridge_points: get value or raise Not_found if None.

val ridge_points_opt : t -> Py.Object.t option

Attribute ridge_points: get value as an option.

val ridge_vertices : t -> Py.Object.t

Attribute ridge_vertices: get value or raise Not_found if None.

val ridge_vertices_opt : t -> Py.Object.t option

Attribute ridge_vertices: get value as an option.

val regions : t -> Py.Object.t

Attribute regions: get value or raise Not_found if None.

val regions_opt : t -> Py.Object.t option

Attribute regions: get value as an option.

val point_region : t -> Py.Object.t

Attribute point_region: get value or raise Not_found if None.

val point_region_opt : t -> Py.Object.t option

Attribute point_region: get value as an option.

val furthest_site : t -> Py.Object.t

Attribute furthest_site: get value or raise Not_found if None.

val furthest_site_opt : t -> Py.Object.t option

Attribute furthest_site: get value as an option.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.