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

Uploaded Source

Built Distributions

numba_kdtree-0.1.1-cp39-cp39-win_amd64.whl (41.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

numba_kdtree-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (513.1 kB view details)

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

numba_kdtree-0.1.1-cp38-cp38-win_amd64.whl (41.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

numba_kdtree-0.1.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (512.0 kB view details)

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

numba_kdtree-0.1.1-cp37-cp37m-win_amd64.whl (41.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

numba_kdtree-0.1.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (515.0 kB view details)

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

numba_kdtree-0.1.1-cp36-cp36m-win_amd64.whl (41.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

numba_kdtree-0.1.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (512.8 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.1.tar.gz.

File metadata

  • Download URL: numba-kdtree-0.1.1.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.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.1.tar.gz
Algorithm Hash digest
SHA256 0555b8c1a98fe65f0ce984651344df43889e9019233be0055d1f055f6e215fcd
MD5 88347f5eb5cd05fb5fe1ca42ca6574a9
BLAKE2b-256 cbd353e9368116da9f768f17d1143744e6e7c1312269ba1472b5585094ffa724

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ddae7f8d141199aa5d0680c8e09abbbe01a2c062ac196ed1ac275dd4ddf868a5
MD5 c6a00ed48fd2e534233c24c5039a2fe7
BLAKE2b-256 edb796f65299c53e157353419183582d4fb97ec76599ea64a950ab81c097eb99

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.1-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.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 49d0a69971cf05519aebbbfcd926a273edbc28bbe200c9496b1111b0ff96b26f
MD5 f2b3d36ccab45c777cbdd3d67c2febf6
BLAKE2b-256 1f6198983849e57df76338e2c702665d7a57dde60c9ed95961f8688e427fb4d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e9b19d97db4e25abe2bd5eaf45c5cb2dc76e24cc4064b49d79c02c40bbaf592b
MD5 d4b098da7f3a7f7fc651d32de4bf7d38
BLAKE2b-256 5017841d95b178f9eacbec3ef90db47c5a68ebda1fa02b4f9e5cf1db65eb1df9

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.1-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.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3e6a09ef477beb8a091feb22702b09b58f16a01547b17c446a2c8cdf5d07c0a4
MD5 6a9e2311d048530ec42e3d0995376159
BLAKE2b-256 0e5e4cb3677c14eb1179e098a2fac29d5ca8c628ac17144db5796a0d61df53c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 55dee5a9196d0108fb1195b5532ac64373bab734d06a93498cf44b180baa407d
MD5 8b46d20b832a6977885aefe83ce81d82
BLAKE2b-256 7a49e26971adc8b8149ea15f137ff1c67e63606c659792fa81dfa077324383e8

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.1-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.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4f86f40a17543403de1a0cb592567cbf90e08455611ea457afa38b66b91057ce
MD5 26c104094a85453775fb7da14a66bbac
BLAKE2b-256 a5db740cf655bc8536733a0ac37290a72c66a687ee52e96ac836fe1a7de88a52

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numba_kdtree-0.1.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 41.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.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.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 4a8e37460e20e9744f3780c0b8a924b2a43788d368a778252c4aa03bcb6b0bc5
MD5 c2ec1f25799a8243ce6dd7750839a0f5
BLAKE2b-256 b9f58b10c6381af7f8838907c5efbaa68e2a38b0867df250f4b5295eceea7f0e

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.1.1-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.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f4f04e06d223ccb260ddc51e6bb3422edf439d0b159b1e742b6c2ca85a014b9a
MD5 5cb7090eb0dbf21f2eeea3b9cf09fe7a
BLAKE2b-256 03bcdce98ebc9b806d8fc60927487fe401bd1d459927f939f496c766123f05b4

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