napf.base.KDT#
- class napf.base.KDT(tree_data, metric=2, leaf_size=10, nthread=1)[source]#
Bases:
object
napf is implemented as template, thus, there are separate classes for each {data_type, dim, metric}. Currently following combinations are supported: data_type: {double, int} dim: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20} metric: {L1, L2}
Given tree_data, creates corresponding core kdt class. Tree is initialized using newtree().
- Parameters:
tree_data ((n, dim) np.ndarray) – Default is None. {double, float, int, long}
metric (int or str) – Default is 2 and distance will be a squared euklidian distance. Valid options are {1, l1, L1, 2, l2, L2}.
leaf_size (int)
nthread (int) – Default thread count for all multi-thread-
- Returns:
core_obj
- Return type:
KDT{data_t}D{dim}L{metric}
Methods
KDT.knn_search
(queries, kneighbors[, nthread])k-nearest-neighbor search.
KDT.newtree
(tree_data[, metric, leaf_size, ...])Given 2D array-like tree_data, it:
KDT.query
(queries[, nthread])scipy-like KDTree query call.
KDT.query_ball_point
(queries, radius, ...[, ...])scipy-like KDTree query_ball_point call.
KDT.radii_search
(queries, radii, return_sorted)Similar to radius_search, but you can specify radius for each query.
KDT.radius_search
(queries, radius, return_sorted)Searches for neighbors in given radius.
KDT.rknn_search
(queries, radius, n_nearest)Searches for k-nearest neighbors within the radius.
KDT.unique_data_and_inverse
(radius[, ...])Finds unique tree data with in given radius tolerance.
Attributes
Returns initialized core tree, if there's any.
Returns dtype of current tree
Returns saved default value for nthread.
Returns data used to initialize core tree.