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.6.tar.gz
(23.5 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.1.6-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 645d12c960c707635ca9a1e00cef51ce52bc614ce8c842d94ab11f198bb08f78 |
|
MD5 | 86f370a7414fa1b001ea4ddb2afe4ee9 |
|
BLAKE2b-256 | 68c086e34a8ae2835d82a77d7841f990b36cc612f776bdc2d50bff5db02590a6 |
Close
Hashes for numba_kdtree-0.1.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3214bf07ce09fb3a4bcc59b9b5dc0d973eb276f420de8e9caf0695208283a40d |
|
MD5 | 59a9f20c06c6228132715bac1126b7b9 |
|
BLAKE2b-256 | 4d09d41c5339540da48296bc93012b905e4575fe552d917bf9fc5f51b53bf6cb |
Close
Hashes for numba_kdtree-0.1.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27405429ff3a11d25d53cf3fd33173252442e166ee4c7d8e8c7e17c3a76a77df |
|
MD5 | bc0ee04cdc470a97de6d5ef90d5f7c57 |
|
BLAKE2b-256 | 0d34f035c3c89da4d8223b9012e800bf0166028ced04528f926236bc5fc46aea |
Close
Hashes for numba_kdtree-0.1.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49305ea7587cf46e083868eb9e5824cfacc411314ff3a32431f7b9312069c6b4 |
|
MD5 | 46617ce049bac4039edfac4258a06ace |
|
BLAKE2b-256 | 04c6b65c98b636c22389be95e817db768d051e2ee39b1c13b0ca6b791a0e52e4 |
Close
Hashes for numba_kdtree-0.1.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97a3e531d6adbb75bef5d83656fa79dd6365520dc517a70fdb6bf1ba83584ff5 |
|
MD5 | 6ddb4ef2bbdea5dbacc40a5249a36d36 |
|
BLAKE2b-256 | 85dfe1601bf8f6dfe6fab7fcaf155a64ee19862618ffba19644d08552c0d058d |
Close
Hashes for numba_kdtree-0.1.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cee6d230c0446c8676449412a2c0b44a178c3b66886e2e444806ae84056627d |
|
MD5 | 6c844a8052abffe236f602e86df76189 |
|
BLAKE2b-256 | 76ddb65b6660f3f91b560b40a061e9fc69f9b44612d6c610615b53061fa33996 |
Close
Hashes for numba_kdtree-0.1.6-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea14c1e1e0e7f73a4cd6078aa39ba08217e370ae9472f9dedd6b93a214462d0 |
|
MD5 | 9e15589a39dbbe3aa4d618abf673aeb0 |
|
BLAKE2b-256 | 8110366fbbfca5ccb67261b172182004f7b088a19595eec0cd60793baf208aab |