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.2.2.tar.gz
(29.0 kB
view hashes)
Built Distributions
Close
Hashes for numba_kdtree-0.2.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5deef2d75ddfa374cb67c7925a8fa001bdbcddcd209ae1828177f43e7f2a6d8 |
|
MD5 | 1dd5eaa30f2de3a779ff3cb0bb9df409 |
|
BLAKE2b-256 | af5adfbc1d3c4b738d1884260ef469eebfec7bda717127d60c43a8479395fa9a |
Close
Hashes for numba_kdtree-0.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0af6e0c82f659d0c2ab627983e63b09f6069dcf0d6eaee02128f84acd2ac83b8 |
|
MD5 | 1b45d80266962b96e9b90711cebb599f |
|
BLAKE2b-256 | e1dbb1859daee8b5a91b7bcd75c7d734ab86bc139ef72567bed0f5524d5d8a31 |
Close
Hashes for numba_kdtree-0.2.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec3b81264827d673ff90990145f57c52243947bc659630364fbf35602fc701de |
|
MD5 | f8cd4328511f41239a1f3c25a9eeb4c7 |
|
BLAKE2b-256 | 537a8d4e2704327b147b4fce7e38583abcdf05fdcd423f104a7d3b6a46e03ba2 |
Close
Hashes for numba_kdtree-0.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d3b7babae90f30846ad384b0fa907dc4004127f18e57e16d83bd94a07d6b029 |
|
MD5 | 3743863b745fa59b3ee801f306e6137d |
|
BLAKE2b-256 | a85bdf0d6cae233241aad6f4f412edeeba66feca015665322579c4600bd15201 |
Close
Hashes for numba_kdtree-0.2.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93b98e68556023337c0c02cb5d8cb978ecbed8ded55fa6476b913787ec202bb8 |
|
MD5 | 7c7db291d51b4db2b0e1408b2c6d1865 |
|
BLAKE2b-256 | 6f1a6e5bc275e76e20649d436454aea500cf7df1bebe5d225ea6b7ada01f79f3 |
Close
Hashes for numba_kdtree-0.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e04d0dacdcaeef9563a0dad6813a73fc743e2f309092f55c510aa29eec4c595b |
|
MD5 | 8587f7a9975c26e607b98c2975e98544 |
|
BLAKE2b-256 | d9bcff58e544cd8f682d7f6f8a08e2498e42649c7d646675fedcf19f1f86a84e |
Close
Hashes for numba_kdtree-0.2.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0295a0884cc515afc58fe9f1e421c8dac23e809cca0a5cafe4c50993bd57644 |
|
MD5 | 32d93bdc253c84b38db07296aa4b1116 |
|
BLAKE2b-256 | c18887babe40017631dc9bbbc8d24f52ae4b24feee4352d350092e4e9d9e3c11 |
Close
Hashes for numba_kdtree-0.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d13345d203d3fac03c809d8385bcd7625b9b11d5e6d9f941610d2af413778cfe |
|
MD5 | 1a489fb10a04d62a496108dd9b81447b |
|
BLAKE2b-256 | 357886acbdde5903b9c5b705ff640986b0663ac53e8f6395ebec7a1ca31958fc |
Close
Hashes for numba_kdtree-0.2.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5866a133f99b7be8623f3b136ed200b5e000be8a53c6ad60049719795df172bc |
|
MD5 | 38839f9f2fd8ac2b06bc189bd5db0427 |
|
BLAKE2b-256 | 61bab7cf406cf67f6def7b5631108e7d508776d3f0a0d9fa4fb193531a0dc037 |
Close
Hashes for numba_kdtree-0.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87d5b4f0431afaad2dc9c0a64c6021ac575af1baf37e5e023baf8c61791c9668 |
|
MD5 | 1b40e0d3a2d21ae5719b2726f20d7484 |
|
BLAKE2b-256 | c31f89ba6ae9ee27446391580bc4bd6f47e8ebce4c3e8fafb507780f1cfa293c |