KDTree

class KDTree(*args)

Partition tree data structure.

Allows to store and search points fast.

Parameters:

sample : 2-d sequence of float

Points.

Examples

>>> import openturns as ot
>>> sample = ot.Normal(2).getSample(10)
>>> tree = ot.KDTree(sample)
>>> neighbour = tree.getNearestNeighbour([0.1, 0.2])

Methods

getClassName() Accessor to the object’s name.
getId() Accessor to the object’s id.
getName() Accessor to the object’s name.
getNearestNeighbour(x) Accessor to the nearest neighbour.
getNearestNeighbourIndex(x) Accessor to the nearest neighbour index.
getNearestNeighbours(x, k) Accessor to the nearest neighbours.
getNearestNeighboursIndices(x, k[, sorted]) Accessor to the nearest neighbours indices.
getPoints() Collection of points accessor.
getShadowedId() Accessor to the object’s shadowed id.
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
insert(point) Insert a point in the tree.
isEmpty() Empty flag accessor.
setName(name) Accessor to the object’s name.
setShadowedId(id) Accessor to the object’s shadowed id.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)
getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getNearestNeighbour(x)

Accessor to the nearest neighbour.

Parameters:

x : sequence of float

Given point.

Returns:

neighbour : Point

Nearest neighbour.

getNearestNeighbourIndex(x)

Accessor to the nearest neighbour index.

Parameters:

x : sequence of float

Given point.

Returns:

index : int

Index of the nearest neighbour.

getNearestNeighbours(x, k)

Accessor to the nearest neighbours.

Parameters:

x : sequence of float

Given point.

k : int

Number of points to return

Returns:

neighbours : Sample

Nearest neighbours.

getNearestNeighboursIndices(x, k, sorted=False)

Accessor to the nearest neighbours indices.

Parameters:

x : sequence of float

Given point.

k : int

Number of points to return

sorted : bool

Whether to return the points sorted

Returns:

indices : Indices

Indices of the k nearest neighbours.

getPoints()

Collection of points accessor.

Returns:

points : Sample

Collection of points.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

insert(point)

Insert a point in the tree.

Parameters:

x : sequence of float

Given point.

isEmpty()

Empty flag accessor.

Returns:

empty : bool

Whether the collection is empty.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.