Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spart"
version = "0.3.0"
version = "0.3.1"
description = "A collection of space partitioning tree data structures for Rust"
repository = "https://github.com/habedi/spart"
license = "MIT OR Apache-2.0"
Expand All @@ -21,15 +21,17 @@ path = "src/lib.rs"

[dependencies]
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
tracing-subscriber = { version = "0.3.19", optional = true }
ordered-float = "5.0.0"
ctor = "0.5.0"
ctor = { version = "0.5.0", optional = true }
serde = { version = "1.0.209", features = ["derive"], optional = true }
bincode = { version = "1.3.3", optional = true }

[features]
default = []
serde = ["dep:serde", "dep:bincode"]
enable_log = ["tracing/log"]
setup_tracing = ["dep:tracing-subscriber", "dep:ctor"]

[dev-dependencies]
criterion = { version = "0.7.0", features = ["html_reports"] }
Expand Down Expand Up @@ -68,6 +70,10 @@ path = "examples/kdtree.rs"
name = "rtree"
path = "examples/rtree.rs"

[[example]]
name = "rstar_tree"
path = "examples/rstar_tree.rs"

[package.metadata.rustfmt]
max_width = 100
hard_tabs = false
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,6 @@ publish-py: wheel-manylinux ## Publish the PySpart wheel to PyPI (requires PYPI_
@echo "Found wheel file: $(WHEEL_FILE)"
@twine upload -u __token__ -p $(PYPI_TOKEN) $(WHEEL_FILE)

.PHONY: generate-ci
generate-ci: ## Generate CI configuration files (GitHub Actions workflow)
@echo "Generating CI configuration files..."
@(cd $(PYSPART_DIR) && maturin generate-ci --zig --pytest --platform all -o ../.github/workflows/ci.yml github)

########################################################################################
## Additional targets
########################################################################################
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[![Tests](https://img.shields.io/github/actions/workflow/status/habedi/spart/tests.yml?label=tests&style=flat&labelColor=282c34&logo=github)](https://github.com/habedi/spart/actions/workflows/tests.yml)
[![Code Coverage](https://img.shields.io/codecov/c/github/habedi/spart?label=coverage&style=flat&labelColor=282c34&logo=codecov)](https://codecov.io/gh/habedi/spart)
[![Code Quality](https://img.shields.io/codefactor/grade/github/habedi/spart?label=quality&style=flat&labelColor=282c34&logo=codefactor)](https://www.codefactor.io/repository/github/habedi/spart)
[![Code Quality](https://img.shields.io/codefactor/grade/github/habedi/spart?label=code%20quality&style=flat&labelColor=282c34&logo=codefactor)](https://www.codefactor.io/repository/github/habedi/spart)
[![Crates.io](https://img.shields.io/crates/v/spart.svg?label=crates.io&style=flat&labelColor=282c34&color=fc8d62&logo=rust)](https://crates.io/crates/spart)
[![Docs.rs](https://img.shields.io/badge/docs-spart-66c2a5?style=flat&labelColor=282c34&logo=docs.rs)](https://docs.rs/spart)
[![MSRV](https://img.shields.io/badge/msrv-1.83.0-informational?style=flat&labelColor=282c34&logo=rust)](https://www.rust-lang.org)
Expand Down Expand Up @@ -36,10 +36,6 @@ At the moment, the following tree data structures and features are supported:
| 4 | [R-tree](https://en.wikipedia.org/wiki/R-tree) | ✓ | ✓ | ✓ | ✓ |
| 5 | [R*-tree](https://en.wikipedia.org/wiki/R*-tree) | ✓ | ✓ | ✓ | ✓ |

> [!IMPORTANT]
> Spart is in early development, so bugs and breaking API changes are expected.
> Please use the [issues page](https://github.com/habedi/spart/issues) to report bugs or request features.

---

### Installation
Expand Down Expand Up @@ -240,8 +236,8 @@ $env:DEBUG_SPART = "true"
- **Supported Geometries and Queries**
- [x] Point data (`Point2D`, `Point3D`)
- [x] kNN search
- [x] Circular or Spherical range search
- [x] Rectangular/Cuboid range search (`range_search_bbox`)
- [x] Circular or spherical range search
- [x] Rectangular and cuboid range search (`range_search_bbox`)
- [ ] `update` method for moving points (currently needs delete + insert)
- [ ] Support for storing non-point geometries (for example, lines, polygons)
- [ ] Advanced intersection queries (like finding all stored items that intersect a given polygon)
Expand Down
11 changes: 4 additions & 7 deletions benches/bench_insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ fn bench_insert<'a, T, P>(
P: Clone,
{
c.bench_function(name, |b| {
b.iter_with_setup(
|| setup(),
|(mut tree, point)| {
insert(&mut tree, point.clone());
black_box(tree);
},
)
b.iter_with_setup(&mut setup, |(mut tree, point)| {
insert(&mut tree, point.clone());
black_box(tree);
})
});
}

Expand Down
18 changes: 12 additions & 6 deletions benches/bench_insert_bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ fn bench_insert_bulk_quadtree_2d(_c: &mut Criterion) {
(tree, points.clone())
},
|(mut tree, points)| {
black_box(tree.insert_bulk(&points));
tree.insert_bulk(&points);
black_box(());
},
)
});
Expand All @@ -40,7 +41,8 @@ fn bench_insert_bulk_octree_3d(_c: &mut Criterion) {
(tree, points.clone())
},
|(mut tree, points)| {
black_box(tree.insert_bulk(&points));
tree.insert_bulk(&points);
black_box(());
},
)
});
Expand Down Expand Up @@ -88,7 +90,8 @@ fn bench_insert_bulk_rtree_2d(_c: &mut Criterion) {
(tree, points.clone())
},
|(mut tree, points)| {
black_box(tree.insert_bulk(points));
tree.insert_bulk(points);
black_box(());
},
)
});
Expand All @@ -104,7 +107,8 @@ fn bench_insert_bulk_rtree_3d(_c: &mut Criterion) {
(tree, points.clone())
},
|(mut tree, points)| {
black_box(tree.insert_bulk(points));
tree.insert_bulk(points);
black_box(());
},
)
});
Expand All @@ -120,7 +124,8 @@ fn bench_insert_bulk_rstartree_2d(_c: &mut Criterion) {
(tree, points.clone())
},
|(mut tree, points)| {
black_box(tree.insert_bulk(points));
tree.insert_bulk(points);
black_box(());
},
)
});
Expand All @@ -136,7 +141,8 @@ fn bench_insert_bulk_rstartree_3d(_c: &mut Criterion) {
(tree, points.clone())
},
|(mut tree, points)| {
black_box(tree.insert_bulk(points));
tree.insert_bulk(points);
black_box(());
},
)
});
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
| 2 | [octree.rs](octree.rs) | Shows the usage of an Octree for inserting 3D points in a defined boundary and performing a kNN search |
| 3 | [quadtree.rs](quadtree.rs) | Shows the usage of a Quadtree for inserting 2D points in a defined boundary and performing a kNN search |
| 4 | [rtree.rs](rtree.rs) | Shows the usage of a 2D and 3D R-tree for inserting points and performing a kNN search |
| 5 | [rstar_tree.rs](rstar_tree.rs) | Shows the usage of an R*-tree for inserting 2D points and performing a kNN search |
| 5 | [rstar_tree.rs](rstar_tree.rs) | Shows the usage of an R*-tree for inserting 2D and 3D points and performing a kNN search |
29 changes: 28 additions & 1 deletion logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "spart"
version = "0.1.0"
description = "Python environment for Spart library"
description = "Python environment for the Spart project"

requires-python = ">=3.10,<4.0"
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion pyspart/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyspart"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
publish = false

Expand Down
4 changes: 4 additions & 0 deletions pyspart/tests/test_core_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def test_rstartree3d():
assert len(results) == 1
assert results[0].data != "p2"


def test_empty_trees():
# Quadtree
boundary = {"x": 0.0, "y": 0.0, "width": 100.0, "height": 100.0}
Expand Down Expand Up @@ -290,6 +291,7 @@ def test_empty_trees():
assert not rst3.range_search(Point3D(0, 0, 0, None), 1)
assert not rst3.delete(Point3D(0, 0, 0, None))


def test_knn_edge_cases():
kd = KdTree2D()
points = [Point2D(1, 2, 'p1'), Point2D(3, 4, 'p2')]
Expand All @@ -301,6 +303,7 @@ def test_knn_edge_cases():
# k > num_points
assert len(kd.knn_search(Point2D(0, 0, None), 5)) == 2


def test_range_zero_radius():
kd = KdTree2D()
p1 = Point2D(1, 2, 'p1')
Expand All @@ -310,6 +313,7 @@ def test_range_zero_radius():
assert len(results) == 1
assert results[0].data == 'p1'


def test_duplicates():
kd = KdTree2D()
p1 = Point2D(1, 2, 'p1')
Expand Down
3 changes: 3 additions & 0 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
//! If `DEBUG_SPART` is not set or is set to a falsy value ("0", "false", or empty),
//! logging will remain disabled. Otherwise, logging is enabled with a maximum level of DEBUG.

#[cfg(feature = "setup_tracing")]
use ctor::ctor;
#[cfg(feature = "setup_tracing")]
use tracing::Level;

#[cfg(feature = "setup_tracing")]
#[ctor]
fn set_debug_level() {
// If DEBUG_SPART is not set or set to a falsy value, disable logging.
Expand Down