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.4.0.tar.gz
(30.7 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.4.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f90adfc98b6a9e3624f52f65044d9e3b3718d3c9cd14b583afe75549807fd0b |
|
MD5 | b96209658a7be6742a591d106413ac88 |
|
BLAKE2b-256 | fc7add47e77ce9c91efd754b5624b2faa9a0163ad3976ae8b846072689ba8748 |
Close
Hashes for numba_kdtree-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff21107ac5b0c9fe8ad3c03bdac78e9f51d02de89ce36b44bca63f584618604a |
|
MD5 | 2bc97d3ae1c52be193e975944be4f18f |
|
BLAKE2b-256 | 55ec9fb3e010608fdfc083cd49fdbc95f74c5870177eaa1a3349869c397750ac |
Close
Hashes for numba_kdtree-0.4.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2463f21999b9288ed9c774373dd456bbf03ddb562aaa0aa4133c868fa99bb51d |
|
MD5 | 6f823ea14e3f5cde3adb621519dd0f7a |
|
BLAKE2b-256 | ac5b7d15843293958cc011783b088694a1a46bb1b25d8c2ed28de2f96cae5e9a |
Close
Hashes for numba_kdtree-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 992d64176e758e441fddf10c9113043676388448f6e138d2fa20758090a6f989 |
|
MD5 | 411e9f80c55db5e774529fd65f747f98 |
|
BLAKE2b-256 | 2ffd14e5a2126353b118c1cce9a1508b533aa5d11fa7a17419a5bd2575d9c7c0 |
Close
Hashes for numba_kdtree-0.4.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32e9916e2cf630ac654d4cdb533b070ee13f857b50ec44a6f99d15f0ed6f6afd |
|
MD5 | 74e03ac42b3430023699f806158ea9d1 |
|
BLAKE2b-256 | d4a34a55679dc203cccca95d2b5b04b2c2684f680518f20f333b8e3c7d73aaa3 |
Close
Hashes for numba_kdtree-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00d758d28389a072287b7fca2972457cb77472b4fa797e55c3e4a4bba359cca4 |
|
MD5 | 204e5ea5b3e716d5060fa1fe7ec796ce |
|
BLAKE2b-256 | e8e5dcba30280bab8abc9556222c77d690ba0330abeea70f41824b26fb4a5179 |
Close
Hashes for numba_kdtree-0.4.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bc2170f81b7caff4bced93dc85e47376a5f57aaf5ac681932938da28b3ad463 |
|
MD5 | b545719ba4693b577561c5b2d1a2bf27 |
|
BLAKE2b-256 | be5e1b382717718fecd4a0eea07c3c173a56f820ecf04ba4f3812979e869b5db |
Close
Hashes for numba_kdtree-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f8591c675323df5003dd4751158c6dda306886da4226ba6df00710f9e947ef1 |
|
MD5 | d5d6dd39c760b0128ef5b46f90ea6f29 |
|
BLAKE2b-256 | fb23a847ff3bfe54c32ecd832f2f52703540c4583bc4fd79463a799e57e7883e |
Close
Hashes for numba_kdtree-0.4.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f065d863bdc16b4a3ec3ab146a9d66913b68312b6c5b2d0d7cc0eb1d57f6ecd |
|
MD5 | e9e8b4c4df87491acdf90cdcb1616e73 |
|
BLAKE2b-256 | 0d248fa9f4d87dffa238f087641543d9757a9d9f4e135dba10188df5623e7ad3 |
Close
Hashes for numba_kdtree-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba1c2c767f3bd991e40cf0f4517585fb0f5b5c5c355f3f165a1306477d077868 |
|
MD5 | 3171d3a79aa9bddbe4a459e80898f599 |
|
BLAKE2b-256 | cdf2c7c468361571a31dccff8e06417018ad3ae9979eab79ac1fe649d0c1cb74 |