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.1.tar.gz
(22.3 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.1.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddae7f8d141199aa5d0680c8e09abbbe01a2c062ac196ed1ac275dd4ddf868a5 |
|
MD5 | c6a00ed48fd2e534233c24c5039a2fe7 |
|
BLAKE2b-256 | edb796f65299c53e157353419183582d4fb97ec76599ea64a950ab81c097eb99 |
Close
Hashes for numba_kdtree-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d0a69971cf05519aebbbfcd926a273edbc28bbe200c9496b1111b0ff96b26f |
|
MD5 | f2b3d36ccab45c777cbdd3d67c2febf6 |
|
BLAKE2b-256 | 1f6198983849e57df76338e2c702665d7a57dde60c9ed95961f8688e427fb4d2 |
Close
Hashes for numba_kdtree-0.1.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9b19d97db4e25abe2bd5eaf45c5cb2dc76e24cc4064b49d79c02c40bbaf592b |
|
MD5 | d4b098da7f3a7f7fc651d32de4bf7d38 |
|
BLAKE2b-256 | 5017841d95b178f9eacbec3ef90db47c5a68ebda1fa02b4f9e5cf1db65eb1df9 |
Close
Hashes for numba_kdtree-0.1.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e6a09ef477beb8a091feb22702b09b58f16a01547b17c446a2c8cdf5d07c0a4 |
|
MD5 | 6a9e2311d048530ec42e3d0995376159 |
|
BLAKE2b-256 | 0e5e4cb3677c14eb1179e098a2fac29d5ca8c628ac17144db5796a0d61df53c0 |
Close
Hashes for numba_kdtree-0.1.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55dee5a9196d0108fb1195b5532ac64373bab734d06a93498cf44b180baa407d |
|
MD5 | 8b46d20b832a6977885aefe83ce81d82 |
|
BLAKE2b-256 | 7a49e26971adc8b8149ea15f137ff1c67e63606c659792fa81dfa077324383e8 |
Close
Hashes for numba_kdtree-0.1.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f86f40a17543403de1a0cb592567cbf90e08455611ea457afa38b66b91057ce |
|
MD5 | 26c104094a85453775fb7da14a66bbac |
|
BLAKE2b-256 | a5db740cf655bc8536733a0ac37290a72c66a687ee52e96ac836fe1a7de88a52 |
Close
Hashes for numba_kdtree-0.1.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a8e37460e20e9744f3780c0b8a924b2a43788d368a778252c4aa03bcb6b0bc5 |
|
MD5 | c2ec1f25799a8243ce6dd7750839a0f5 |
|
BLAKE2b-256 | b9f58b10c6381af7f8838907c5efbaa68e2a38b0867df250f4b5295eceea7f0e |
Close
Hashes for numba_kdtree-0.1.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4f04e06d223ccb260ddc51e6bb3422edf439d0b159b1e742b6c2ca85a014b9a |
|
MD5 | 5cb7090eb0dbf21f2eeea3b9cf09fe7a |
|
BLAKE2b-256 | 03bcdce98ebc9b806d8fc60927487fe401bd1d459927f939f496c766123f05b4 |