• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    Python
  • Created about 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple and fast KD-tree for points in Python for kNN or nearest points. (damm short at just ~60 lines) No libraries needed.

Python KD-Tree for Points

A simple and decently performant KD-Tree in Python.

Just about 60 lines of code excluding comments.

It's so simple that you can just copy and paste, or translate to other languages!
Your teacher will assume that you are a good student who coded it from scratch.

Why?

No external dependencies like numpy, scipy, etc.

Supports points that are array-like: lists, arrays, numpy arrays.

Just star this project if you find it helpful... so others can know it's better than those long winded kd-tree codes. ;)

Requirements

Python 2.x or 3.x

Dependencies

None

Notes

Creation of the KD-Tree isn't strictly O(n log (n)), but is similar O(n log (n)) in practice.
It abuses Python's native sort (TimSort) which is O(n) for nearly sorted lists.

Adding too many points relative to the number of points in the tree can degrade performance.
If you are adding many new points into the tree, it is better to re-create the tree.

License

CC0

More Repositories

1

solady

Optimized Solidity snippets.
Solidity
2,349
star
2

dn404

Implementation of a co-joined ERC20 and ERC721 pair.
Solidity
463
star
3

multicaller

Efficient multicaller contracts
Solidity
260
star
4

closedsea

Optimized and flexible version of OpenSea's operator filterer
Solidity
130
star
5

soledge

Solidity snippets too edgy to be in Solady
Solidity
107
star
6

Aris

Aris - A fast and powerful tool to write HTML in JS easily. Includes syntax highlighting, templates, SVG, CSS autofixing, debugger support and more...
JavaScript
88
star
7

function-selector-miner

Solidity Function Selector Miner (AVX2 + Multithreaded)
Rust
62
star
8

Static-Sort

A simple C++ header-only library for fastest sorting of small arrays. Generates sorting networks on compile time via templates.
C++
51
star
9

preapprove

On-chain pre-approval registry for NFTs. Library included.
Solidity
42
star
10

Fluidsim

A C++ fluid simulator (SPH, OpenCL, GLSL, SSE, Fast Marching Cubes)
C++
19
star
11

Othello-AI

A strong Othello AI bot for 50.021 Artificial Intelligence course.
Python
12
star
12

VoxNet-Tensorflow

A Tensorflow Implementation of VoxNet.
Python
11
star
13

QDES

Quadratic Decay Exponential Surge
Solidity
11
star
14

Softee

Solidity
7
star
15

vectorized

5
star
16

foundry-starter

Script to initialize a foundry project in the current working directory
Shell
4
star
17

Sort-Me

A Realtime Multiplayer Sorting Game for Android
Java
3
star
18

Solidity-Code-Reviews

2
star
19

ERC721A-Upgradeable-Old

Upgradeable version of ERC721A
Solidity
2
star
20

Python-Attribute-List

Add/set attributes to Python's built-in list.
Python
1
star
21

NFTStaker

Solidity
1
star
22

ERC721A-Docs

ERC721A Documentation
1
star
23

ERC721A-Transpiler

Transpiler for creating upgradable ERC721A
TypeScript
1
star
24

SUTD-Staff-Room-Maps-old-Dover-edition

An Android App for navigating the staff room in SUTD's old Dover Campus.
Java
1
star
25

CECSATSolver

CEC-SAT verification software for ISTD 2D Design Challenge
Java
1
star
26

solady-copy

Solidity
1
star