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

Uploaded Source

Built Distributions

numba_kdtree-0.3.0-cp311-cp311-win_amd64.whl (44.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

numba_kdtree-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.3.0-cp310-cp310-win_amd64.whl (44.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

numba_kdtree-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.3.0-cp39-cp39-win_amd64.whl (44.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

numba_kdtree-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.3.0-cp38-cp38-win_amd64.whl (44.3 kB view details)

Uploaded CPython 3.8 Windows x86-64

numba_kdtree-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.3.0-cp37-cp37m-win_amd64.whl (44.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

numba_kdtree-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479.4 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: numba-kdtree-0.3.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for numba-kdtree-0.3.0.tar.gz
Algorithm Hash digest
SHA256 96c74547711cfb5a96a2336a7300b7e42c4f67e2f64bc479170d6a5c6261cb5c
MD5 b1bb8eb71b392e5f39b8999efd2ba2ef
BLAKE2b-256 01ccebf7a5c10c3231392b84cc41cca998b54d5c191ca2730fdeff95ecfc2455

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 194ffd69dcf498f7032903e0a0defe92414c3f7fe9e8b23d8c3c7dd165dfde99
MD5 d82bc19d528830dc99ad37e21c84ab37
BLAKE2b-256 5caaba0925a5940eb6247903764977cfde3c2bb52e26dc55bda288c31e59f480

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ee1f03ed1859376343e38b54ec18f300b07358bf4b5e6cf6c9641d1af96bd57
MD5 59722585f673e3b75dd15ab366ddb29f
BLAKE2b-256 f29b67d7597058e762d6b15a64eb1f21ecef96a8e18f0334739c5e3afc3abf40

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5e227b52b3c59d30235daf0c8adb3710a6b55fa70399c347638a8d552aa56a0e
MD5 0334c634016f9c306993f11b55a960bf
BLAKE2b-256 465912685e35e9a6f66d4fafd433b83bdc02bd18f6e63fd6b9bb1af83c86eeb6

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 41e60a6aa3296a6bf78e3e62ad3ae26e4f0a444541eb6b8407351cf847507e6b
MD5 8eda5bece7d647b9b92049f9ea5595d6
BLAKE2b-256 520ea79b31aba93de6c4b9ff2850058c18913079b7f4fd3d4a7ecb59e1262713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d5eff65e082b4368d172c8029e3857aa411f0da13b097cad77e90d657c75ab0d
MD5 2c0f199fbbfe90618cdae62105e59446
BLAKE2b-256 e58ca06e2b848f739a2a073f87a903e3105788b3214ac1c0130d41065f5d76e6

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb0c5aa6356d32e78c846306e5bdc5a0964c81f332b063c5f23c6446548cdf79
MD5 7237b3523cfcb4b30d3461d67fb5274b
BLAKE2b-256 2c609ae0012ec098beeeba54795fb5405dbc654c8d0ae8235bc8b5e9ee37670e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dc43cf3b5bcc9b177acc562ee6f9db77d32da4679edb7ac1796766a4c8f01f08
MD5 f6f7dba61ed882c87a9f0f3efd2606ae
BLAKE2b-256 1362dbe46f93e6e18bc5df1824dfaf78e989772525f4ea59722d2accff86cb73

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c7ab6c834c8e67dbcd96fb9e18d5f33a17abc64e82e7dca9329fc5ca3fc22d33
MD5 8c297d02af0740c0208392d9c0e23fdc
BLAKE2b-256 6f771b1e68b11a94fc19fbbccea52b9152c8c449b9e22922753049336a9f264b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 381aaf7bad53d4ad2ef52cf55ae712e54204ddb22e9aa2e4014d8e230e6826b9
MD5 3c9400047eeba11bdba5ce6334f50fb6
BLAKE2b-256 a98f42169885c455771322fcda5133340fcdbd99adc4384ca7a11f1cfecd1dc9

See more details on using hashes here.

File details

Details for the file numba_kdtree-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for numba_kdtree-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 331250af7f8e7648cb140c9d53b8e2630cd72001660597ea79c6073438879009
MD5 c0694de6d5c73e0664e31f281086f4a5
BLAKE2b-256 51729d214e85b519246535c4527a1f1f848d3e5841747415a62d4e7fe5c164ce

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