Code¶
-
class
cykdtree.
PyKDTree
¶ Construct a KDTree for a set of points.
Parameters: - pts (np.ndarray of double) – (n,m) array of n coordinates in a m-dimensional domain.
- left_edge (np.ndarray of double) – (m,) domain minimum in each dimension.
- right_edge (np.ndarray of double) – (m,) domain maximum in each dimension.
- periodic (bool or np.ndarray of bool, optional) – Truth of the domain periodicity overall (if bool), or in each dimension (if np.ndarray). Defaults to False.
- leafsize (int, optional) – The maximum number of points that should be in a leaf. Defaults to 10000.
- nleaves (int, optional) – The number of leaves that should be in the resulting tree. If greater than 0, leafsize is adjusted to produce a tree with 2**(ceil(log2(nleaves))) leaves. Defaults to 0.
Raises: ValueError
– If leafsize < 2. This currectly segfaults.-
npts
¶ uint64 – Number of points in the tree.
-
ndim
¶ uint32 – Number of dimensions points occupy.
-
num_leaves
¶ uint32 – Number of leaves in the tree.
-
leafsize
¶ uint32 – Maximum number of points a leaf can have.
-
leaves
¶ list of cykdtree.PyNode – Tree leaves.
-
idx
¶ np.ndarray of uint64 – Indices sorting the points by leaf.
-
left_edge
¶ np.ndarray of double – (m,) domain minimum in each dimension.
-
right_edge
¶ np.ndarray of double – (m,) domain maximum in each dimension.
-
domain_width
¶ np.ndarray of double – (m,) domain width in each dimension.
-
periodic
¶ np.ndarray of bool – Truth of domain periodicity in each dimension.
-
get
()¶ Return the leaf containing a given position.
Parameters: pos (np.ndarray of double) – Coordinates. Returns: Leaf containing pos. Return type: cykdtree.PyNode
Raises: ValueError
– If pos is not contained withing the KDTree.
-
get_neighbor_ids
()¶ Return the IDs of leaves containing & neighboring a given position.
Parameters: pos (np.ndarray of double) – Coordinates. Returns: Leaves containing/neighboring pos. Return type: np.ndarray of uint32 Raises: ValueError
– If pos is not contained withing the KDTree.
-
leaf_idx
()¶ Get array of indices for points in a leaf.
Parameters: leafid (np.uint32_t) – Unique index of the leaf in question. Returns: Indices of points belonging to leaf. Return type: np.ndarray of np.uint64_t
-
class
cykdtree.
PyNode
¶ A container for leaf info.
-
npts
¶ np.uint64_t – Number of points in this node.
-
ndim
¶ np.uint32_t – Number of dimensions in domain.
-
num_leaves
¶ np.uint32_t – Number of leaves in the tree containing this node.
-
start_idx
¶ np.uint64_t – Index where indices for this node begin.
-
stop_idx
¶ np.uint64_t – One passed the end of indices for this node.
-
left_edge
¶ np.ndarray of float64 – Minimum bounds of this node in each dimension.
-
right_edge
¶ np.ndarray of float64 – Maximum bounds of this node in each dimension.
-
periodic_left
¶ np.ndarray of bool – Periodicity of minimum bounds.
-
periodic_right
¶ np.ndarray of bool – Periodicity of maximum bounds.
-
domain_width
¶ np.ndarray of float64 – Width of the total domain in each dimension.
-
left_neighbors
¶ list of lists – Indices of neighbor leaves at the minimum bounds in each dimension.
-
right_neighbors
¶ list of lists – Indices of neighbor leaves at the maximum bounds in each dimension.
-
neighbors
¶ list of int – Indices of all neighboring leaves including this leaf.
-
slice
¶ slice – Slice of kdtree indices contained by this node.
-
-
class
cykdtree.
PyKDTree
Construct a KDTree for a set of points.
Parameters: - pts (np.ndarray of double) – (n,m) array of n coordinates in a m-dimensional domain.
- left_edge (np.ndarray of double) – (m,) domain minimum in each dimension.
- right_edge (np.ndarray of double) – (m,) domain maximum in each dimension.
- periodic (bool or np.ndarray of bool, optional) – Truth of the domain periodicity overall (if bool), or in each dimension (if np.ndarray). Defaults to False.
- leafsize (int, optional) – The maximum number of points that should be in a leaf. Defaults to 10000.
- nleaves (int, optional) – The number of leaves that should be in the resulting tree. If greater than 0, leafsize is adjusted to produce a tree with 2**(ceil(log2(nleaves))) leaves. Defaults to 0.
Raises: ValueError
– If leafsize < 2. This currectly segfaults.-
npts
uint64 – Number of points in the tree.
-
ndim
uint32 – Number of dimensions points occupy.
-
num_leaves
uint32 – Number of leaves in the tree.
-
leafsize
uint32 – Maximum number of points a leaf can have.
-
leaves
list of cykdtree.PyNode – Tree leaves.
-
idx
np.ndarray of uint64 – Indices sorting the points by leaf.
-
left_edge
np.ndarray of double – (m,) domain minimum in each dimension.
-
right_edge
np.ndarray of double – (m,) domain maximum in each dimension.
-
domain_width
np.ndarray of double – (m,) domain width in each dimension.
-
periodic
np.ndarray of bool – Truth of domain periodicity in each dimension.
-
get
() Return the leaf containing a given position.
Parameters: pos (np.ndarray of double) – Coordinates. Returns: Leaf containing pos. Return type: cykdtree.PyNode
Raises: ValueError
– If pos is not contained withing the KDTree.
-
get_neighbor_ids
() Return the IDs of leaves containing & neighboring a given position.
Parameters: pos (np.ndarray of double) – Coordinates. Returns: Leaves containing/neighboring pos. Return type: np.ndarray of uint32 Raises: ValueError
– If pos is not contained withing the KDTree.
-
leaf_idx
() Get array of indices for points in a leaf.
Parameters: leafid (np.uint32_t) – Unique index of the leaf in question. Returns: Indices of points belonging to leaf. Return type: np.ndarray of np.uint64_t
-
class
cykdtree.
PyNode
A container for leaf info.
-
npts
np.uint64_t – Number of points in this node.
-
ndim
np.uint32_t – Number of dimensions in domain.
-
num_leaves
np.uint32_t – Number of leaves in the tree containing this node.
-
start_idx
np.uint64_t – Index where indices for this node begin.
-
stop_idx
np.uint64_t – One passed the end of indices for this node.
-
left_edge
np.ndarray of float64 – Minimum bounds of this node in each dimension.
-
right_edge
np.ndarray of float64 – Maximum bounds of this node in each dimension.
-
periodic_left
np.ndarray of bool – Periodicity of minimum bounds.
-
periodic_right
np.ndarray of bool – Periodicity of maximum bounds.
-
domain_width
np.ndarray of float64 – Width of the total domain in each dimension.
-
left_neighbors
list of lists – Indices of neighbor leaves at the minimum bounds in each dimension.
-
right_neighbors
list of lists – Indices of neighbor leaves at the maximum bounds in each dimension.
-
neighbors
list of int – Indices of all neighboring leaves including this leaf.
-
slice
slice – Slice of kdtree indices contained by this node.
-