A pure Python Quadtree implementation.
Project description
quads
A pure Python Quadtree implementation.
Quadtrees are a useful data structure for sparse datasets where the position of the data is important. They're especially for spatial indexing & image processing.
Usage
>>> import quads
>>> tree = quads.QuadTree(
... (0, 0), # The center point
... 10, # The width
... 10, # The height
... )
# You can choose to simply represent points that exist.
>>> tree.insert((1, 2))
True
# ...or include extra data at those points.
>>> tree.insert(quads.Point(4, -3, data="Samus"))
True
# You can search for a given point. It returns the point if found...
>>> tree.find((1, 2))
Point(1, 2)
# Or `None` if there's no match.
>>> tree.find((4, -4))
None
# You can also find all the points within a given region.
>>> bb = quads.BoundingBox(min_x=-1, min_y=-2, max_x=2, max_y=2)
>>> tree.within_bb(bb)
[Point(1, 2)]
Setup
$ pip install quads
Requirements
- Python 3.7+ (untested on older versions but may work)
Running Tests
$ git clone https://github.com/toastdriven/quads.git
$ cd quads
$ poetry install
$ pytest .
License
New BSD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
quads-1.0.0b0.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file quads-1.0.0b0.tar.gz
.
File metadata
- Download URL: quads-1.0.0b0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.4 Darwin/19.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3678845fbb33d88c74273dc2ae29b594ab8e951d0dcdd7e5e5a09cf2e9bcf93c |
|
MD5 | c77077112d466beafd8d07da73868a07 |
|
BLAKE2b-256 | e1a9a610eaca1cef6998b82c3c8ce902a6052a27bddec89c38699be6409efb3a |
File details
Details for the file quads-1.0.0b0-py3-none-any.whl
.
File metadata
- Download URL: quads-1.0.0b0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.4 Darwin/19.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ff34a8fac0397194e0009ad752677fcb012833de25916dd2d168291b497c47c |
|
MD5 | 58de92d4f16f37dd538e3dde74aaebba |
|
BLAKE2b-256 | 2a448d7b0e47e79821e0a04760f29c56c3debfaccc5ef8dfe9df4b2209604b42 |