RegularGridNearestNeighbour¶
- class RegularGridNearestNeighbour(*args)¶
Partition tree data structure.
Allows one to store and search points fast.
- Parameters:
- grid
RegularGrid
Regular grid
- grid
Methods
Accessor to the object's name.
getName
()Accessor to the object's name.
Get the points which have been used to build this nearest neighbour algorithm.
hasName
()Test if the object is named.
query
(*args)Get the index of the nearest neighbour of the given point.
queryK
(x, k[, sorted])Get the indices of nearest neighbours of the given point.
queryScalar
(*args)Accessor to the nearest neighbour index.
queryScalarK
(x, k[, sorted])Accessor to the nearest neighbours indices.
setName
(name)Accessor to the object's name.
setSample
(sample)Build a NearestNeighbourAlgorithm from these points.
See also
Examples
>>> import openturns as ot >>> myRegularGrid = ot.RegularGrid(0.0, 0.1, 100) >>> tree = ot.RegularGridNearestNeighbour(myRegularGrid) >>> neighbour = tree.queryScalar(0.1)
- __init__(*args)¶
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- getSample()¶
Get the points which have been used to build this nearest neighbour algorithm.
- Returns:
- sample
Sample
Input points.
- sample
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- query(*args)¶
Get the index of the nearest neighbour of the given point.
- Available usages:
query(point)
query(sample)
- Parameters:
- pointsequence of float
Given point.
- sample2-d sequence of float
Given points.
- Returns:
- indexint
Index of the nearest neighbour of the given point.
- indices
Indices
Index of the nearest neighbour of the given points.
- queryK(x, k, sorted=False)¶
Get the indices of nearest neighbours of the given point.
- Parameters:
- xsequence of float
Given point.
- kint
Number of indices to return.
- sortedbool, optional
Boolean to tell whether returned indices are sorted according to the distance to the given point.
- Returns:
- indicessequence of int
Indices of the k nearest neighbours of the given point.
- queryScalar(*args)¶
Accessor to the nearest neighbour index.
- Available usages:
queryScalar(x)
queryScalar(point)
- Parameters:
- xfloat
Given 1D point.
- pointsequence of float
Sequence of 1D points.
- Returns:
- indexint
Index of the nearest neighbour.
- indices
Indices
Index of the nearest neighbour of the given points.
- queryScalarK(x, k, sorted=False)¶
Accessor to the nearest neighbours indices.
- Parameters:
- xfloat
Given 1D point.
- kint
Number of indices to return.
- sortedbool
Boolean to tell whether returned indices are sorted according to the distance to the given point.
- Returns:
- indices
Indices
Indices of the k nearest neighbours.
- indices
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.