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.4.tar.gz
(23.0 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.1.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12dfd44f59aeb35361e8a12d83aecd936d00672d80b4fddada866e463ee81435 |
|
MD5 | 9a5e1e7e3f92243805601e293f518891 |
|
BLAKE2b-256 | 37cb0028de39ce0de7c2bb98d246b1ed3fd6363ce15498ad60bca39c54e5540e |
Close
Hashes for numba_kdtree-0.1.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cc447692d9dac46918e13ff1143ac940c3d5830ef424b524942602e3e2844f3 |
|
MD5 | e2b35241807d96079888c628ea27711a |
|
BLAKE2b-256 | d3def4d840cd0c35a89b5fab6d14198b349ff140ceb98392e755bbfd6abbd35d |
Close
Hashes for numba_kdtree-0.1.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5173b6afb91a1a241fb0e98894ac5db92a02c1f9b8b5d5afd7f63bc2f33a5792 |
|
MD5 | c460a7ee2e68b85164b83ba4259b293e |
|
BLAKE2b-256 | a54560a1f4db11d9ba6f8fdfa5638f153b92ed7d38508ed0bf406a171516959c |
Close
Hashes for numba_kdtree-0.1.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aea706c40d3617365569358b5fcba2fa073fcaebc7db8c8ffd67cd38271662f |
|
MD5 | ec83ef1187d3344d489d66e2ccbeca67 |
|
BLAKE2b-256 | 451b8645e340d8cbec4236bcaf56a19d520e61bba0160b41fc442c5b229e0953 |
Close
Hashes for numba_kdtree-0.1.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83d4d9c6855e5f8d6ea48a7dc484caf05507459e06a994b74f4e9d4d860b8695 |
|
MD5 | fff05436a7eadc21aa7f0795120eee56 |
|
BLAKE2b-256 | 778ba9bb2a4324ac805a477ee9ca4907f2672201fbe3601d3c6565caa9fe5d04 |
Close
Hashes for numba_kdtree-0.1.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e400cc046c5b096aa810cd7d1d93f6ea6d214025edb2c1ebb34b545f25ae4b2 |
|
MD5 | b6a1d53db43d5cda0d748e7524bf42ec |
|
BLAKE2b-256 | eb22c14be8af1bfc1d0e4acab1866b4be18c5559ca82f31532faaa7f5ce5bbe0 |
Close
Hashes for numba_kdtree-0.1.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13bc5d97cb1664fd3d9f7b3da823e9b3767f1917bae757e7a10644478622b46f |
|
MD5 | b24b28a426b28ce1acc15383f6473ac9 |
|
BLAKE2b-256 | 9137a0cd88ebe796bf5a1cd354fafa5a0785bb5ac779685e4d50e68294e09424 |
Close
Hashes for numba_kdtree-0.1.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1fe510fb25c585cf81b7b15d3e98f31b7d5b6f6c5ad672122da17ce33b3748 |
|
MD5 | eaf5841d9d09181f384b7e6e64ec9ea2 |
|
BLAKE2b-256 | f6ddf5e8622628560a4874192582209cc651829eb8d64c7ebfd86b940d094916 |