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

Uploaded Source

Built Distributions

numba_kdtree-0.1.4-cp39-cp39-win_amd64.whl (42.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

numba_kdtree-0.1.4-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.4-cp38-cp38-win_amd64.whl (42.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

numba_kdtree-0.1.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (513.9 kB view details)

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

numba_kdtree-0.1.4-cp37-cp37m-win_amd64.whl (42.1 kB view details)

Uploaded CPython 3.7m Windows x86-64

numba_kdtree-0.1.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (516.6 kB view details)

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

numba_kdtree-0.1.4-cp36-cp36m-win_amd64.whl (42.1 kB view details)

Uploaded CPython 3.6m Windows x86-64

numba_kdtree-0.1.4-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.4.tar.gz.

File metadata

  • Download URL: numba-kdtree-0.1.4.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for numba-kdtree-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3e736a13b58c932fb7f4496e2271031ceaac5b9b4e19f31bb034d68e0bac3daa
MD5 d327490c24e93e2867ec47759358879e
BLAKE2b-256 edb482b8f2524a3ddd1b2db274d42258bfbf5cd23e33eb65f9929abf35831084

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 12dfd44f59aeb35361e8a12d83aecd936d00672d80b4fddada866e463ee81435
MD5 9a5e1e7e3f92243805601e293f518891
BLAKE2b-256 37cb0028de39ce0de7c2bb98d246b1ed3fd6363ce15498ad60bca39c54e5540e

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.4-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.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2cc447692d9dac46918e13ff1143ac940c3d5830ef424b524942602e3e2844f3
MD5 e2b35241807d96079888c628ea27711a
BLAKE2b-256 d3def4d840cd0c35a89b5fab6d14198b349ff140ceb98392e755bbfd6abbd35d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5173b6afb91a1a241fb0e98894ac5db92a02c1f9b8b5d5afd7f63bc2f33a5792
MD5 c460a7ee2e68b85164b83ba4259b293e
BLAKE2b-256 a54560a1f4db11d9ba6f8fdfa5638f153b92ed7d38508ed0bf406a171516959c

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.4-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.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 8aea706c40d3617365569358b5fcba2fa073fcaebc7db8c8ffd67cd38271662f
MD5 ec83ef1187d3344d489d66e2ccbeca67
BLAKE2b-256 451b8645e340d8cbec4236bcaf56a19d520e61bba0160b41fc442c5b229e0953

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 83d4d9c6855e5f8d6ea48a7dc484caf05507459e06a994b74f4e9d4d860b8695
MD5 fff05436a7eadc21aa7f0795120eee56
BLAKE2b-256 778ba9bb2a4324ac805a477ee9ca4907f2672201fbe3601d3c6565caa9fe5d04

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.4-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.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2e400cc046c5b096aa810cd7d1d93f6ea6d214025edb2c1ebb34b545f25ae4b2
MD5 b6a1d53db43d5cda0d748e7524bf42ec
BLAKE2b-256 eb22c14be8af1bfc1d0e4acab1866b4be18c5559ca82f31532faaa7f5ce5bbe0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for numba_kdtree-0.1.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 13bc5d97cb1664fd3d9f7b3da823e9b3767f1917bae757e7a10644478622b46f
MD5 b24b28a426b28ce1acc15383f6473ac9
BLAKE2b-256 9137a0cd88ebe796bf5a1cd354fafa5a0785bb5ac779685e4d50e68294e09424

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.4-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.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9c1fe510fb25c585cf81b7b15d3e98f31b7d5b6f6c5ad672122da17ce33b3748
MD5 eaf5841d9d09181f384b7e6e64ec9ea2
BLAKE2b-256 f6ddf5e8622628560a4874192582209cc651829eb8d64c7ebfd86b940d094916

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