NearestNeighbour1D¶

class
NearestNeighbour1D
(*args)¶ Partition tree data structure for 1D points.
Allows to store and search 1D points fast, by using dichotomy on sorted points.
 Parameters
 sample
Sample
1D points
 sample
See also
Examples
>>> import openturns as ot >>> myRegularGrid = ot.RegularGrid(0.0, 0.1, 100) >>> tree = ot.NearestNeighbour1D([[x] for x in myRegularGrid.getValues()]) >>> neighbour = tree.queryScalar(0.1)
Methods
getClassName
(self)Accessor to the object’s name.
getId
(self)Accessor to the object’s id.
getName
(self)Accessor to the object’s name.
getSample
(self)Get the points which have been used to build this nearest neighbour algorithm.
getShadowedId
(self)Accessor to the object’s shadowed id.
getVisibility
(self)Accessor to the object’s visibility state.
hasName
(self)Test if the object is named.
hasVisibleName
(self)Test if the object has a distinguishable name.
query
(self, \*args)Get the index of the nearest neighbour of the given point.
queryK
(self, x, k[, sorted])Get the indices of nearest neighbours of the given point.
queryScalar
(self, \*args)Accessor to the nearest neighbour index.
queryScalarK
(self, x, k[, sorted])Accessor to the nearest neighbours indices.
setName
(self, name)Accessor to the object’s name.
setSample
(self, sample)Build a NearestNeighbourAlgorithm from these points.
setShadowedId
(self, id)Accessor to the object’s shadowed id.
setVisibility
(self, visible)Accessor to the object’s visibility state.

__init__
(self, *args)¶ Initialize self. See help(type(self)) for accurate signature.

getClassName
(self)¶ Accessor to the object’s name.
 Returns
 class_namestr
The object class name (object.__class__.__name__).

getId
(self)¶ Accessor to the object’s id.
 Returns
 idint
Internal unique identifier.

getName
(self)¶ Accessor to the object’s name.
 Returns
 namestr
The name of the object.

getSample
(self)¶ Get the points which have been used to build this nearest neighbour algorithm.
 Returns
 sample
Sample
Input points.
 sample

getShadowedId
(self)¶ Accessor to the object’s shadowed id.
 Returns
 idint
Internal unique identifier.

getVisibility
(self)¶ Accessor to the object’s visibility state.
 Returns
 visiblebool
Visibility flag.

hasName
(self)¶ Test if the object is named.
 Returns
 hasNamebool
True if the name is not empty.

hasVisibleName
(self)¶ Test if the object has a distinguishable name.
 Returns
 hasVisibleNamebool
True if the name is not empty and not the default one.

query
(self, *args)¶ Get the index of the nearest neighbour of the given point.
 Available usages:
query(point)
query(sample)
 Parameters
 pointsequence of float
Given point.
 sample2d sequence of float
Given points.
 Returns
 indexint
Index of the nearest neighbour of the given point.
 indices
openturns.Indices
Index of the nearest neighbour of the given points.

queryK
(self, 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
(self, *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
openturns.Indices
Index of the nearest neighbour of the given points.

queryScalarK
(self, 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
(self, name)¶ Accessor to the object’s name.
 Parameters
 namestr
The name of the object.

setSample
(self, sample)¶ Build a NearestNeighbourAlgorithm from these points.
 Parameters
 sample
Sample
Input points.
 sample

setShadowedId
(self, id)¶ Accessor to the object’s shadowed id.
 Parameters
 idint
Internal unique identifier.

setVisibility
(self, visible)¶ Accessor to the object’s visibility state.
 Parameters
 visiblebool
Visibility flag.