A kdtree implementation for numba.
Project description
Numba-kdtree
A simple KD-Tree for numba using a ctypes wrapper around the scipy ckdtree
implementation.
The KD-Tree is usable in both python and numba nopython functions.
Once the query functions are compiled by numba, the implementation is just as fast as the original scipy version.
Note: Currently only a basic subset of the original ckdtree
interface is implemented.
Installation
Using pip
pip install numba-kdtree
From source
git clone https://github.com/mortacious/numba-kdtree.git
cd numba-kdtree
python setup.py install
Usage
import numpy as np
from numba_kdtree import KDTree
data = np.random.random(3_000_000).reshape(-1, 3)
kdtree = KDTree(data, leafsize=10)
# query the nearest neighbors of the first 100 points
distances, indices = kdtree.query(data[:100], k=30)
# query all points in a radius around the first 100 points
indices = kdtree.query_radius(data[:100], r=0.5, return_sorted=True)
The KDTree
can also be used from within numba functions
import numpy as np
from numba import njit
from numba_kdtree import KDTree
def numba_function_with_kdtree(kdtree, data):
for i in range(data.shape[0]):
distances, indices = kdtree.query(data[0], k=30)
#<Use the computed neighbors
data = np.random.random(3_000_000).reshape(-1, 3)
kdtree = KDTree(data, leafsize=10)
numba_function_with_kdtree(kdtree, data[:10000])
TODOs
- Implement all scipy
ckdtree
functions - Fix the parallel query functions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
numba-kdtree-0.1.7.tar.gz
(25.5 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.1.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de99eacc6bbd61506fb20eccb360972c29a0941ea838b11e9859328919fc6a23 |
|
MD5 | af53c4a6b7d86ef4394001197936bbe6 |
|
BLAKE2b-256 | e9049ed6296c5eebafdf334994f56c54f269226385b10262c37b4b4c4b357ade |
Close
Hashes for numba_kdtree-0.1.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4cfd8f57e5341f323d2eada62ef3659eb3c42db996ca0fc47d94289e81ea8c2 |
|
MD5 | ce4851aeff50b07f27ba5521cc976f51 |
|
BLAKE2b-256 | 49b035fcca7a8c43e286b80b1fe2b1c5effbeb030f79feb8f35c6965ae59af6d |
Close
Hashes for numba_kdtree-0.1.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bf4abc9c74dc3a0926e74ef0bd7c662f2098cda7d35f9ac195e54a3a44ad42f |
|
MD5 | ef1cbec20434c49940665d318c38f449 |
|
BLAKE2b-256 | 4c3361446754a2d5fd006086b8b799dab8f8a027eb4208301f31854c01bf2173 |
Close
Hashes for numba_kdtree-0.1.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f116db7978ad981f8282587a77c18c2737ef0b62bede367eec207ea94b007080 |
|
MD5 | eb883badbc5214e0ba54f145d70517ae |
|
BLAKE2b-256 | c429e90b7776113d266d8c05a76056f55a6cf786bcee4735ef2f8c54ce14b0d8 |
Close
Hashes for numba_kdtree-0.1.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b1ab2902e84a92fcce8c38e591b6ce43fa018bc8e67f848e598893e5f3cd102 |
|
MD5 | aa79e5e5b631c9627ded96e43c332f6b |
|
BLAKE2b-256 | c3e41cd91b64f905bcbda39f396630ab6ce033d7074dfa57f14511d51ce8831c |
Close
Hashes for numba_kdtree-0.1.7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a84bf1dc782ba14377f4dff642269cbc4e36d9118784bf19ab293d799e0c30f1 |
|
MD5 | 4e4c11e6ec41b53b9054d8422f60895d |
|
BLAKE2b-256 | 2a1642eab84e976336491daa9adf5b1de8f9f2bc2775107e01292ece1aca1883 |
Close
Hashes for numba_kdtree-0.1.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd5fe25b5210c4c9ae06d8d3110186ff5d12403a47cfc4055f6b492c2d377e2b |
|
MD5 | 623998cc98cdd5be5708a9639620638d |
|
BLAKE2b-256 | 410ecf00f823026aa5438623742801f7d29e59432038e4ad3ad24f8afe5e756a |