Skip to main content

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


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.2.tar.gz (23.0 kB view details)

Uploaded Source

Built Distributions

numba_kdtree-0.1.2-cp39-cp39-win_amd64.whl (41.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

numba_kdtree-0.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (513.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

numba_kdtree-0.1.2-cp38-cp38-win_amd64.whl (42.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

numba_kdtree-0.1.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (512.3 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

numba_kdtree-0.1.2-cp37-cp37m-win_amd64.whl (42.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

numba_kdtree-0.1.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (515.2 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

numba_kdtree-0.1.2-cp36-cp36m-win_amd64.whl (42.0 kB view details)

Uploaded CPython 3.6m Windows x86-64

numba_kdtree-0.1.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (513.0 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.5+ x86-64

File details

Details for the file numba-kdtree-0.1.2.tar.gz.

File metadata

  • Download URL: numba-kdtree-0.1.2.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for numba-kdtree-0.1.2.tar.gz
Algorithm Hash digest
SHA256 89c6fa66c1c7790763b35f2e6086700956356f6d4a85765258dc20fc408bf3a6
MD5 9b8ef3986b898f792f6861b46e82c246
BLAKE2b-256 793dc93c71a825bb017409c87618bb5e5ada7791d6d97939a27d8ea148d00395

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: numba_kdtree-0.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 78a8b6462e350b32c68486a1448cba78a7577a9bcad46308cfc82b22cdf39a3f
MD5 329fc078ab8d4f41f15a4c7b128b0b5f
BLAKE2b-256 914f5d3e9fdf5b8a05d267f19fd36a158b7ea8caf95fe9f887122597c91b7835

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.1.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 057ed48ce5a90bb2205b990f79a4acdfa02a1aa851c575dfb1d1d02ddf233c89
MD5 43c95a12d1f305f9e6c273f71aefd60f
BLAKE2b-256 28f056e61f5100169e3a3d30990f91a6d4818a17c4c8b2ae1e80d2c965f15d7b

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: numba_kdtree-0.1.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 484e9c9d82e21402673a1f57272c0ee96c5536bf8f6f7f64d6bbb40f6065f223
MD5 b6ea729107d21afb08bf30a949045d68
BLAKE2b-256 92e4c4e9f160f8a401ba2840de55d802bc38edfd706871fe2bf2b60dd7210b72

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.1.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d2b2048886d28245458286ec13f25e387d6cd4a379b91581752fb46ec80be666
MD5 eab738de8b95d2ffea7b985b20eb434e
BLAKE2b-256 73ad0c897e2f04b67ba8de37aee465ea02d20a1168b1a1c117a16954ba2e41b5

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: numba_kdtree-0.1.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 47461effdcaaf7311fa5446bee1d82fbf216684d2f51f82a54fec552f329c6f7
MD5 1e3ee79c3d7cd1871cd9d6633226e222
BLAKE2b-256 a1aaf73c1726ccdfc9b86d412afc87b5e1fb260a9e150b57878b6a47849264c1

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.1.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 36ad9e902dcf9e27ffc330a7b1f254c89c3cbfd4a00ec68338016b0c46ce5cd2
MD5 b0b923bb24e974f6128ec8f096bb0e3f
BLAKE2b-256 9381eb963318bddcbba56e6899c21e0ef49085acf317bb25d02fcabc6d23bbf8

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: numba_kdtree-0.1.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3022e13ecaa03d0b54436e11036d9aa2c66f1b3d453fe39a5b3c9d5aab388d61
MD5 107fd1fbb83decd289132a9801bdc314
BLAKE2b-256 42084b5fdc4dc2ba5ff4e4a5ad4f5e645f17ad8dc80ed69751f0cfa31fd08e0b

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.1.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 e0b2b3f280c26b2893e2a6680231e4d45ca8d4a400fd9e5e898a1bac1234bf14
MD5 51601060d676027fbd0ede4f670a9fb0
BLAKE2b-256 d1dad2b9a3f1a75acd27b3ac7deecc313756a464562280ef9b00be4108a201a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page