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.3.tar.gz
(23.0 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.1.3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 483cc274aaba2994e62067bcdf32d99791a431f7664fb03f7cafafd792e89294 |
|
MD5 | cd2eab5753109b8a1452f9554fa87922 |
|
BLAKE2b-256 | 80d71da807b31423109f52f9e8c74f8ee86052cd7325f9f2f5bc61b48b19f1af |
Close
Hashes for numba_kdtree-0.1.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bdfbc9c379d399a34b6b7bcd56d9d38377aec8417683170611a888a3a4e3a13 |
|
MD5 | 5b8840a5e5a37b454e87c6cf44c0f0f5 |
|
BLAKE2b-256 | 00f660c3f5fd54ea231e247bbc176f576a1c62e65f05680e2e2b94693b89a411 |
Close
Hashes for numba_kdtree-0.1.3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2648d26d6153f28772ca8409b616252800ae37e0da56c5c1d79342929bdb34bb |
|
MD5 | 91b914b97d32775b7ad55e50dde5223b |
|
BLAKE2b-256 | 9722d9d0f6992a79378a0a8111173d2f1b504091e9b5ae9f140dd1f3266655b4 |
Close
Hashes for numba_kdtree-0.1.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f940e68ec95f6788182057e2d55ba2ea10b1599330816d5c5b8dd3d691e116b |
|
MD5 | 1905db366934b6e7573ada28cd732be3 |
|
BLAKE2b-256 | b4e692f67dc1f68b705b6818bad002e51b00a04e346767be42603cde360872fc |
Close
Hashes for numba_kdtree-0.1.3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4234540e657705481308bde2957aa0739ebb795d700a05c3fcd58f9794fce2a |
|
MD5 | 25c99186ff3368abc70ea2797d525b69 |
|
BLAKE2b-256 | 58b9b172e0c297a6f435c87b259fda18c915814e691fc23db05af8fc60a47496 |
Close
Hashes for numba_kdtree-0.1.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a31db3720acc6ea8257a5e4e597a6bad82e9ef0adb864d2d5e0ce93008a99aa |
|
MD5 | adbe7a5ddeb4dfb2c5eb8c55e529db47 |
|
BLAKE2b-256 | 2bfc7cf72299dd9c7dcfddf89af65adcc6dfe56cc6208f626819beb1ba84d093 |
Close
Hashes for numba_kdtree-0.1.3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f71c45e81059eb6300a043b25cbe3c7da0888a7090500bb3914352dfa117091 |
|
MD5 | 42935622d8314b4e3e76f10c44fb4879 |
|
BLAKE2b-256 | 08f11ee8671efc90db91dd3188a5e4d90a1e1d818cbd8faa22e4759f042cc0e2 |
Close
Hashes for numba_kdtree-0.1.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52f5da780970f61c7b8e8f12b240f2bcf96fc1d325942abdb72c32dc6d03601d |
|
MD5 | 8fc943f91c72294e7150c2a577fcd9fe |
|
BLAKE2b-256 | 76d8503724ee095afb99bb9223702151fc1c0a755b886f3113b36ba7a840889f |