PySpart
Python bindings for the Spart library.
Installation
pip install pyspart
Examples
Below are some examples of how to use the different trees in PySpart.
Quadtree (2D)
from pyspart import Quadtree, Point2D
# Define the bounding area for the Quadtree.
boundary = {"x": 0.0, "y": 0.0, "width": 10.0, "height": 10.0}
# Create a new Quadtree with a maximum capacity of 3 points per node.
tree = Quadtree(boundary, 3)
# Define some 2D points.
point1 = Point2D(1.0, 2.0, "Point1")
point2 = Point2D(3.0, 4.0, "Point2")
point3 = Point2D(5.0, 6.0, "Point3")
point4 = Point2D(7.0, 8.0, "Point4")
point5 = Point2D(2.0, 3.0, "Point5")
# Insert points into the Quadtree.
tree.insert(point1)
tree.insert(point2)
tree.insert(point3)
tree.insert(point4)
tree.insert(point5)
# Perform a k-nearest neighbor (kNN) search.
neighbors = tree.knn_search(point1, 2)
print(f"kNN search results for {point1}: {neighbors}")
# Perform a range search with a radius of 5.0.
range_points = tree.range_search(point1, 5.0)
print(f"Range search results for {point1}: {range_points}")
# Remove a point from the tree.
tree.delete(point1)
Octree (3D)
from pyspart import Octree, Point3D
# Define the bounding area for the Octree.
boundary = {"x": 0.0, "y": 0.0, "z": 0.0, "width": 10.0, "height": 10.0, "depth": 10.0}
# Create a new Octree with a maximum capacity of 3 points per node.
tree = Octree(boundary, 3)
# Define some 3D points.
point1 = Point3D(1.0, 2.0, 3.0, "Point1")
point2 = Point3D(3.0, 4.0, 5.0, "Point2")
point3 = Point3D(5.0, 6.0, 7.0, "Point3")
point4 = Point3D(7.0, 8.0, 9.0, "Point4")
point5 = Point3D(2.0, 3.0, 4.0, "Point5")
# Insert points into the Octree.
tree.insert(point1)
tree.insert(point2)
tree.insert(point3)
tree.insert(point4)
tree.insert(point5)
# Perform a kNN search.
neighbors = tree.knn_search(point1, 2)
print(f"kNN search results for {point1}: {neighbors}")
# Perform a range search with a radius of 5.0.
range_points = tree.range_search(point1, 5.0)
print(f"Range search results for {point1}: {range_points}")
# Remove a point from the tree.
tree.delete(point1)
Kd-tree (3D)
from pyspart import KdTree3D, Point3D
# Create a new Kd-tree for 3D points.
tree = KdTree3D()
# Define some 3D points.
point1 = Point3D(1.0, 2.0, 3.0, "Point1")
point2 = Point3D(3.0, 4.0, 5.0, "Point2")
point3 = Point3D(5.0, 6.0, 7.0, "Point3")
point4 = Point3D(7.0, 8.0, 9.0, "Point4")
point5 = Point3D(2.0, 3.0, 4.0, "Point5")
# Insert points into the Kd-tree.
tree.insert(point1)
tree.insert(point2)
tree.insert(point3)
tree.insert(point4)
tree.insert(point5)
# Perform a kNN search.
neighbors = tree.knn_search(point1, 2)
print(f"kNN search results for {point1}: {neighbors}")
# Perform a range search with a radius of 5.0.
range_points = tree.range_search(point1, 5.0)
print(f"Range search results for {point1}: {range_points}")
# Remove a point from the tree.
tree.delete(point1)
R-tree (3D)
from pyspart import RTree3D, Point3D
# Create a new R-tree with a maximum capacity of 4 points per node.
tree = RTree3D(4)
# Define some 3D points.
point1 = Point3D(1.0, 2.0, 3.0, "Point1")
point2 = Point3D(3.0, 4.0, 5.0, "Point2")
point3 = Point3D(5.0, 6.0, 7.0, "Point3")
point4 = Point3D(7.0, 8.0, 9.0, "Point4")
point5 = Point3D(2.0, 3.0, 4.0, "Point5")
# Insert points into the R-tree.
tree.insert(point1)
tree.insert(point2)
tree.insert(point3)
tree.insert(point4)
tree.insert(point5)
# Perform a kNN search.
neighbors = tree.knn_search(point1, 2)
print(f"kNN search results for {point1}: {neighbors}")
# Perform a range search with a radius of 5.0.
range_points = tree.range_search(point1, 5.0)
print(f"Range search results for {point1}: {range_points}")
# Remove a point from the tree.
tree.delete(point1)
R*-tree (3D)
from pyspart import RStarTree3D, Point3D
# Create a new R*-tree with a maximum capacity of 4 points per node.
tree = RStarTree3D(4)
# Define some 3D points.
point1 = Point3D(1.0, 2.0, 3.0, "Point1")
point2 = Point3D(3.0, 4.0, 5.0, "Point2")
point3 = Point3D(5.0, 6.0, 7.0, "Point3")
point4 = Point3D(7.0, 8.0, 9.0, "Point4")
point5 = Point3D(2.0, 3.0, 4.0, "Point5")
# Insert points into the R*-tree.
tree.insert(point1)
tree.insert(point2)
tree.insert(point3)
tree.insert(point4)
tree.insert(point5)
# Perform a kNN search.
neighbors = tree.knn_search(point1, 2)
print(f"kNN search results for {point1}: {neighbors}")
# Perform a range search with a radius of 5.0.
range_points = tree.range_search(point1, 5.0)
print(f"Range search results for {point1}: {range_points}")
# Remove a point from the tree.
tree.delete(point1)
Check out the examples directory for more examples.
Serialization
In Python, you can use the save and load methods to serialize and deserialize the tree to and from a file:
from pyspart import Quadtree, Point2D
# Create a Quadtree and insert some points
boundary = {"x": 0.0, "y": 0.0, "width": 100.0, "height": 100.0}
qt = Quadtree(boundary, 4)
qt.insert(Point2D(10.0, 20.0, "point1"))
qt.insert(Point2D(50.0, 50.0, "point2"))
# Save the tree to a file
qt.save("quadtree.spart")
# Load the tree from the file
loaded_qt = Quadtree.load("quadtree.spart")
License
PySpart is licensed under the MIT License.
Metadata
Release files for pyspart 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyspart-0.6.2.tar.gz | 186.3 kB | Without provenance | Details for pyspart-0.6.2.tar.gz |
Built distributions (wheels)
Total release size: 3.3 MB
Release files / pyspart-0.6.2.tar.gz
| Download URL | pyspart-0.6.2.tar.gz |
|---|---|
| Size | 186.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
185217658165057279cd297b7bece48a1644b030c290fd68ad2e11abefffe319
|
|
BLAKE2b-256 checksum How to use checksums |
6162a5d3349c4eb71a632d81ba109525f1f93b3dd5e63db1c9e988c037d04934
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-win_arm64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 332.1 kB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
6985861c20471f75b45c6569b51f12646fca4238d19e48fadbc3b10235d94bc3
|
|
BLAKE2b-256 checksum How to use checksums |
1354b1e5f3107eedeff6361ba484c5aed6d5cdd4f379351502ebdf56d619291d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-win_amd64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 361.6 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c324d319969e9f33f63621536320c4e7677a3dc727e82bc72e63d5065e854218
|
|
BLAKE2b-256 checksum How to use checksums |
552ad5b3076b536d31ea13798a201905e00f024eb6ecba80d1fbfe650aa8690c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 436.3 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
159e97ec86d60d68e21ef1bf46959ec2919f76e4074ab800802776310c739b51
|
|
BLAKE2b-256 checksum How to use checksums |
e4d786ffdc90ae79a9c396bd6f465d74ebf2e65e5213f926e2443443f9522ac2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 398.0 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
108a7c87a38099d48f64b651b950c45f0f0328a630b8017dd1227d763cfa8d64
|
|
BLAKE2b-256 checksum How to use checksums |
4c20223268c545d18a44dc22a0bf35f6f764e46edcbd2e6939ac5215239f4f36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 437.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ff9f805b0839532a88be565516e7a0e424486377ac2d05938d65ef221021abea
|
|
BLAKE2b-256 checksum How to use checksums |
aca72bd55e8c7d6e4be9090baeb731d5079ca41365de2c4a202af1ea3dd685de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 401.7 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
27e12bc302bbe83a22725000714e32313de8191dd59033c7f9b20485b5031ad0
|
|
BLAKE2b-256 checksum How to use checksums |
4f0f29ecdd1da501dfed68f2143b3de2d009aad6a5d4834966693d910f93faa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 377.4 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
da6acf3468d826fb5468970120ba1af6445eb8647613416ca9ca0ab83bf834be
|
|
BLAKE2b-256 checksum How to use checksums |
36ee5f94aa0479c14b844d5c667737482e492e48875665d47e9d085f8543d605
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pyspart-0.6.2-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | pyspart-0.6.2-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 403.6 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
263c87ffba8f133f8e084b7951c8fee2914eb7576da4c924487659487b118cb5
|
|
BLAKE2b-256 checksum How to use checksums |
8046a2c68d9c2bd30381965e46af381d9391b58e9b9702709f9cd7b4b48d5483
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pyspart 0.6.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.