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

Uploaded Source

Built Distributions

numba_kdtree-0.4.0-cp311-cp311-win_amd64.whl (45.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

numba_kdtree-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.4.0-cp310-cp310-win_amd64.whl (45.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

numba_kdtree-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.4.0-cp39-cp39-win_amd64.whl (45.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

numba_kdtree-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.4.0-cp38-cp38-win_amd64.whl (45.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

numba_kdtree-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

numba_kdtree-0.4.0-cp37-cp37m-win_amd64.whl (45.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

numba_kdtree-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.5 kB view details)

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

File details

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

File metadata

  • Download URL: numba-kdtree-0.4.0.tar.gz
  • Upload date:
  • Size: 30.7 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.4.0.tar.gz
Algorithm Hash digest
SHA256 449ba313b684e475739e9542efbe48283a02cb1da63f9309239d17791b432c49
MD5 b34b374be30a54bab544c3f82b87a5a4
BLAKE2b-256 8e14486001f2c1e81ff703ad430df8d349dad85e7a81332259ae508279250121

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0f90adfc98b6a9e3624f52f65044d9e3b3718d3c9cd14b583afe75549807fd0b
MD5 b96209658a7be6742a591d106413ac88
BLAKE2b-256 fc7add47e77ce9c91efd754b5624b2faa9a0163ad3976ae8b846072689ba8748

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff21107ac5b0c9fe8ad3c03bdac78e9f51d02de89ce36b44bca63f584618604a
MD5 2bc97d3ae1c52be193e975944be4f18f
BLAKE2b-256 55ec9fb3e010608fdfc083cd49fdbc95f74c5870177eaa1a3349869c397750ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2463f21999b9288ed9c774373dd456bbf03ddb562aaa0aa4133c868fa99bb51d
MD5 6f823ea14e3f5cde3adb621519dd0f7a
BLAKE2b-256 ac5b7d15843293958cc011783b088694a1a46bb1b25d8c2ed28de2f96cae5e9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 992d64176e758e441fddf10c9113043676388448f6e138d2fa20758090a6f989
MD5 411e9f80c55db5e774529fd65f747f98
BLAKE2b-256 2ffd14e5a2126353b118c1cce9a1508b533aa5d11fa7a17419a5bd2575d9c7c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 32e9916e2cf630ac654d4cdb533b070ee13f857b50ec44a6f99d15f0ed6f6afd
MD5 74e03ac42b3430023699f806158ea9d1
BLAKE2b-256 d4a34a55679dc203cccca95d2b5b04b2c2684f680518f20f333b8e3c7d73aaa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00d758d28389a072287b7fca2972457cb77472b4fa797e55c3e4a4bba359cca4
MD5 204e5ea5b3e716d5060fa1fe7ec796ce
BLAKE2b-256 e8e5dcba30280bab8abc9556222c77d690ba0330abeea70f41824b26fb4a5179

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2bc2170f81b7caff4bced93dc85e47376a5f57aaf5ac681932938da28b3ad463
MD5 b545719ba4693b577561c5b2d1a2bf27
BLAKE2b-256 be5e1b382717718fecd4a0eea07c3c173a56f820ecf04ba4f3812979e869b5db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f8591c675323df5003dd4751158c6dda306886da4226ba6df00710f9e947ef1
MD5 d5d6dd39c760b0128ef5b46f90ea6f29
BLAKE2b-256 fb23a847ff3bfe54c32ecd832f2f52703540c4583bc4fd79463a799e57e7883e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9f065d863bdc16b4a3ec3ab146a9d66913b68312b6c5b2d0d7cc0eb1d57f6ecd
MD5 e9e8b4c4df87491acdf90cdcb1616e73
BLAKE2b-256 0d248fa9f4d87dffa238f087641543d9757a9d9f4e135dba10188df5623e7ad3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for numba_kdtree-0.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba1c2c767f3bd991e40cf0f4517585fb0f5b5c5c355f3f165a1306477d077868
MD5 3171d3a79aa9bddbe4a459e80898f599
BLAKE2b-256 cdf2c7c468361571a31dccff8e06417018ad3ae9979eab79ac1fe649d0c1cb74

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