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 distancer
of point(s)pts
.query_ball_tree
(other, r[, p, eps])Find all pairs of Atoms
whose distance is at morer
.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 distancer
of point(s)pts
.query_ball_tree
(other, r[, p, eps])Find all pairs of Atoms
whose distance is at morer
.query_pairs
(r[, p, eps])Find all pairs of points within a distance r
.Attributes Documentation
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 fromself
andx2
drawn fromother
, and wheredistance(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
- other (
-
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 asd
.
-
query_ball_point
(pts, r, p=2.0, eps=0)[source] [edit on github][source]¶ Find all
Atoms
within distancer
of point(s)pts
.Parameters: - pts (
Point
) – ThePoint
orPoints
to search for neighbors of. - r (positive
float
) – The radius ofKDTAtoms
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: - pts (
-
query_ball_tree
(other, r, p=2.0, eps=0)[source] [edit on github][source]¶ Find all pairs of
Atoms
whose distance is at morer
.Parameters: - other (
KDTree
) – The tree containing points to search against - r (positive
float
) – The radius ofKDTAtoms
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: - other (
-
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:
-