KDTreeAtomsMixin

class sknano.core.atoms.mixins.KDTreeAtomsMixin[source] [edit on github][source]

Bases: object

Mixin Atoms class for KDTree analysis.

Attributes

atom_tree KDTree of atom coordinates.

Methods

count_neighbors(other, r[, p]) Count how many nearby neighbor pairs can be formed.
query_atom_tree([k, eps, p, rc]) Query atom tree for nearest neighbors distances and indices.
query_ball_point(pts, r[, p, eps]) Find all Atoms within distance r of point(s) pts.
query_ball_tree(other, r[, p, eps]) Find all pairs of Atoms whose distance is at more r.
query_pairs(r[, p, eps]) Find all pairs of points within a distance r.

Attributes Summary

atom_tree KDTree of atom coordinates.

Methods Summary

count_neighbors(other, r[, p]) Count how many nearby neighbor pairs can be formed.
query_atom_tree([k, eps, p, rc]) Query atom tree for nearest neighbors distances and indices.
query_ball_point(pts, r[, p, eps]) Find all Atoms within distance r of point(s) pts.
query_ball_tree(other, r[, p, eps]) Find all pairs of Atoms whose distance is at more r.
query_pairs(r[, p, eps]) Find all pairs of points within a distance r.

Attributes Documentation

atom_tree

KDTree of atom coordinates.

Methods Documentation

count_neighbors(other, r, p=2.0)[source] [edit on github][source]

Count how many nearby neighbor pairs can be formed.

Count the number of pairs (x1, x2) that can be formed, with x1 drawn from self and x2 drawn from other, and where distance(x1, x2, p) <= r.

Parameters:
  • other (KDTree) –
  • r (float or one-dimensional array of floats) –
  • p (float, 1<=p<=infinity, optional) –
Returns:

result

Return type:

int or 1-D array of ints

query_atom_tree(k=16, eps=0, p=2, rc=inf)[source] [edit on github][source]

Query atom tree for nearest neighbors distances and indices.

Parameters:
  • k (integer) – The number of nearest neighbors to return.
  • eps (nonnegative float) – Return approximate nearest neighbors; the kth returned value is guaranteed to be no further than (1+eps) times the distance to the real kth nearest neighbor.
  • p (float, 1<=p<=infinity) – Which Minkowski p-norm to use. 1 is the sum-of-absolute-values “Manhattan” distance 2 is the usual Euclidean distance infinity is the maximum-coordinate-difference distance
  • rc (nonnegative float) – Radius cutoff. Return only neighbors within this distance. This is used to prune tree searches, so if you are doing a series of nearest-neighbor queries, it may help to supply the distance to the nearest neighbor of the most recent point.
Returns:

  • d (array of floats) – The distances to the nearest neighbors, sorted by distance.
  • i (array of integers) – The locations of the neighbors in self.atom_tree.data. i is the same shape as d.

query_ball_point(pts, r, p=2.0, eps=0)[source] [edit on github][source]

Find all Atoms within distance r of point(s) pts.

Parameters:
  • pts (Point) – The Point or Points to search for neighbors of.
  • r (positive float) – The radius of KDTAtoms to return
  • p (float, 1<=p<=infinity) – Which Minkowski p-norm to use. 1 is the sum-of-absolute-values “Manhattan” distance 2 is the usual Euclidean distance infinity is the maximum-coordinate-difference distance
  • eps (nonnegative float, optional) – Approximate search.
Returns:

Return type:

Atoms

query_ball_tree(other, r, p=2.0, eps=0)[source] [edit on github][source]

Find all pairs of Atoms whose distance is at more r.

Parameters:
  • other (KDTree) – The tree containing points to search against
  • r (positive float) – The radius of KDTAtoms to return
  • p (float, 1<=p<=infinity) – Which Minkowski p-norm to use. 1 is the sum-of-absolute-values “Manhattan” distance 2 is the usual Euclidean distance infinity is the maximum-coordinate-difference distance
  • eps (nonnegative float, optional) – Approximate search.
Returns:

Return type:

Atoms

query_pairs(r, p=2.0, eps=0)[source] [edit on github][source]

Find all pairs of points within a distance r.

Parameters:
  • r (positive float) –
  • p (float, optional) –
  • eps (float, optional) –
Returns:

results

Return type:

set