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.8.tar.gz
(25.7 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.1.8-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9b083cf4a4007c22034ceb64b0abf7d8eaf9b1717558dd2da174099e82138a3 |
|
MD5 | 7f9c53b180ed4937c3478428b3ee057a |
|
BLAKE2b-256 | e38a99ae90e7a6160c3bfc9f9ed83893c8a481342480a2f5b2f1b1377384eb0c |
Close
Hashes for numba_kdtree-0.1.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a0fd42b3d8076b61af09390ab6fcd32c68cdf165034f4b4f2cd3342ae8139a4 |
|
MD5 | 926c8e679900bda141ad38006eca5926 |
|
BLAKE2b-256 | f55494a5b6b39ea2b8b4cdbb701fca02a4cddf6e47906fd2abc794671e351d99 |
Close
Hashes for numba_kdtree-0.1.8-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ed13644dae0fa041decc2c9a64cad18880e45546de61d5353e139cb7b30811 |
|
MD5 | 701221cf273a8cad2306e37982108a51 |
|
BLAKE2b-256 | 30deabc234f1c3f913f9ef8edabcd983e034a85e164d66a511fe20f4c3cb10b1 |
Close
Hashes for numba_kdtree-0.1.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fa6ede851cd24082d7cb08add77f1fec0153f0c00eee1050dc0c65e141d5d6d |
|
MD5 | df2f2f151e19de99c456e735dc98aaf6 |
|
BLAKE2b-256 | 8d883265978bb21e6584e38849d05934eea12e479c235024880cf95fe57c4daa |
Close
Hashes for numba_kdtree-0.1.8-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6963c2e91151d656aef0d05f19f7de03e57e1a561ecbbfe14b7978956be8da76 |
|
MD5 | e0765480ad8945b24d6c810ef211b50c |
|
BLAKE2b-256 | ab5a48c041f1b121ef87b99646c032b7a56efc6eeb530e9fe7480a24abbd472f |
Close
Hashes for numba_kdtree-0.1.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4297b959f644c81377b1663c61686c8ab73d8f20f7059589c56430d72b3958a2 |
|
MD5 | 4d7bdda0ad634cbbf082a60feab804c8 |
|
BLAKE2b-256 | 9219578f6d101973a30f0062d4c686019106a526eafb263298688a1876fe37d3 |
Close
Hashes for numba_kdtree-0.1.8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cc697807df00931af43a6011c8e575570fa010ae282065e34902c8fb0e99d7f |
|
MD5 | 72d60d6dd3466c9ec9e9f355a20b10e1 |
|
BLAKE2b-256 | 2975a4aba140c7b9310760a6548087cd1f8f3ef46d69bb22d7a90308494cd526 |
Close
Hashes for numba_kdtree-0.1.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc5e35d154101c2452f03d4d8a21d02250367032d35e31c5cf609d247b480da0 |
|
MD5 | 046d1c4f16bfa90a00fa60a3da738bf9 |
|
BLAKE2b-256 | aa275e2b91aa27d8bc0f484bb24b721b9997b7bfb166bf2f60a109d3ee868b83 |
Close
Hashes for numba_kdtree-0.1.8-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb534f7223e55ff5f7fc1c5ee5ebe46e162786f54108e7e6b9b9abcbb863f26b |
|
MD5 | 5a5f59e17a6af241e8b27bb28eabe0a8 |
|
BLAKE2b-256 | 2538e1ae02123ac856c0934dddb2102c830fa8b36ff95a0bf8f90d3f708429d6 |
Close
Hashes for numba_kdtree-0.1.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fdb803a68c6d56caebcab21e1a41a8b327f4af58c63f948ff57c99e7e2f9abe |
|
MD5 | c924b0c19dc66cf68cac17e705bf82d8 |
|
BLAKE2b-256 | 1b2afc68f67bbaa4dcb88445be67534ce2f65d16624932824cf051abced20921 |