fastquadtree 0.8.1__cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.9.1__cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,131 @@
1
+ """
2
+ Python Shim to mimic the interface of pyqtree and allow for a
3
+ drop-in replacement to fastquadtree.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Any, Tuple
9
+
10
+ from ._native import RectQuadTree
11
+
12
+ Point = Tuple[float, float] # only for type hints in docstrings
13
+
14
+ # Default parameters from pyqtree
15
+ MAX_ITEMS = 10
16
+ MAX_DEPTH = 20
17
+
18
+
19
+ class Index:
20
+ """
21
+ The class below is taken from the pyqtree package, but the implementation
22
+ has been modified to use the fastquadtree package as a backend instead of
23
+ the original pure-python implementation.
24
+
25
+
26
+ The top spatial index to be created by the user. Once created it can be
27
+ populated with geographically placed members that can later be tested for
28
+ intersection with a user inputted geographic bounding box. Note that the
29
+ index can be iterated through in a for-statement, which loops through all
30
+ all the quad instances and lets you access their properties.
31
+
32
+ Example usage:
33
+
34
+ >>> spindex = Index(bbox=(0, 0, 100, 100))
35
+ >>> spindex.insert('duck', (50, 30, 53, 60))
36
+ >>> spindex.insert('cookie', (10, 20, 15, 25))
37
+ >>> spindex.insert('python', (40, 50, 95, 90))
38
+ >>> results = spindex.intersect((51, 51, 86, 86))
39
+ >>> sorted(results)
40
+ ['duck', 'python']
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ bbox=None,
46
+ x=None,
47
+ y=None,
48
+ width=None,
49
+ height=None,
50
+ max_items=MAX_ITEMS,
51
+ max_depth=MAX_DEPTH,
52
+ ):
53
+ """
54
+ Initiate by specifying either 1) a bbox to keep track of, or 2) with an xy centerpoint and a width and height.
55
+
56
+ Parameters:
57
+ - **bbox**: The coordinate system bounding box of the area that the quadtree should
58
+ keep track of, as a 4-length sequence (xmin,ymin,xmax,ymax)
59
+ - **x**:
60
+ The x center coordinate of the area that the quadtree should keep track of.
61
+ - **y**
62
+ The y center coordinate of the area that the quadtree should keep track of.
63
+ - **width**:
64
+ How far from the xcenter that the quadtree should look when keeping track.
65
+ - **height**:
66
+ How far from the ycenter that the quadtree should look when keeping track
67
+ - **max_items** (optional): The maximum number of items allowed per quad before splitting
68
+ up into four new subquads. Default is 10.
69
+ - **max_depth** (optional): The maximum levels of nested subquads, after which no more splitting
70
+ occurs and the bottommost quad nodes may grow indefinately. Default is 20.
71
+ """
72
+ if bbox is not None:
73
+ x1, y1, x2, y2 = bbox
74
+ self._qt = RectQuadTree((x1, y1, x2, y2), max_items, max_depth=max_depth)
75
+
76
+ elif (
77
+ x is not None and y is not None and width is not None and height is not None
78
+ ):
79
+ self._qt = RectQuadTree(
80
+ (x - width / 2, y - height / 2, x + width / 2, y + height / 2),
81
+ max_items,
82
+ max_depth=max_depth,
83
+ )
84
+
85
+ else:
86
+ raise ValueError(
87
+ "Either the bbox argument must be set, or the x, y, width, and height arguments must be set"
88
+ )
89
+
90
+ self._id_to_obj: dict[int, Any] = {}
91
+
92
+ def insert(self, item: Any, bbox): # pyright: ignore[reportIncompatibleMethodOverride]
93
+ """
94
+ Inserts an item into the quadtree along with its bounding box.
95
+
96
+ Parameters:
97
+ - **item**: The item to insert into the index, which will be returned by the intersection method
98
+ - **bbox**: The spatial bounding box tuple of the item, with four members (xmin,ymin,xmax,ymax)
99
+ """
100
+ self._id_to_obj[id(item)] = item
101
+ self._qt.insert(id(item), bbox)
102
+
103
+ def remove(self, item, bbox):
104
+ """
105
+ Removes an item from the quadtree.
106
+
107
+ Parameters:
108
+ - **item**: The item to remove from the index
109
+ - **bbox**: The spatial bounding box tuple of the item, with four members (xmin,ymin,xmax,ymax)
110
+
111
+ Both parameters need to exactly match the parameters provided to the insert method.
112
+ """
113
+ self._qt.delete(id(item), bbox)
114
+
115
+ # Pops
116
+ self._id_to_obj.pop(id(item), None)
117
+
118
+ def intersect(self, bbox):
119
+ """
120
+ Intersects an input boundingbox rectangle with all of the items
121
+ contained in the quadtree.
122
+
123
+ Parameters:
124
+ - **bbox**: A spatial bounding box tuple with four members (xmin,ymin,xmax,ymax)
125
+
126
+ Returns:
127
+ - A list of inserted items whose bounding boxes intersect with the input bbox.
128
+ """
129
+ results = self._qt.query(bbox)
130
+ # result = (id, x0, y0, x1, y1)
131
+ return [self._id_to_obj[result[0]] for result in results]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastquadtree
3
- Version: 0.8.1
3
+ Version: 0.9.1
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3 :: Only
6
6
  Classifier: Programming Language :: Rust
@@ -24,6 +24,7 @@ Requires-Dist: mkdocs-autorefs ; extra == 'dev'
24
24
  Requires-Dist: mkdocs-git-revision-date-localized-plugin ; extra == 'dev'
25
25
  Requires-Dist: mkdocs-minify-plugin ; extra == 'dev'
26
26
  Requires-Dist: maturin>=1.5 ; extra == 'dev'
27
+ Requires-Dist: pyqtree==1.0.0 ; extra == 'dev'
27
28
  Provides-Extra: dev
28
29
  License-File: LICENSE
29
30
  Summary: Rust-accelerated quadtree for Python with fast inserts, range queries, and k-NN search.
@@ -38,33 +39,54 @@ Project-URL: Issues, https://github.com/Elan456/fastquadtree/issues
38
39
 
39
40
  # fastquadtree
40
41
 
41
- [![Docs](https://img.shields.io/badge/docs-online-brightgreen)](https://elan456.github.io/fastquadtree/)
42
- [![PyPI version](https://img.shields.io/pypi/v/fastquadtree.svg)](https://pypi.org/project/fastquadtree/)
43
- [![Python versions](https://img.shields.io/pypi/pyversions/fastquadtree.svg)](https://pypi.org/project/fastquadtree/)
44
- [![Wheels](https://img.shields.io/pypi/wheel/fastquadtree.svg)](https://pypi.org/project/fastquadtree/#files)
45
- [![License: MIT](https://img.shields.io/pypi/l/fastquadtree.svg)](LICENSE)
42
+ <img src="https://raw.githubusercontent.com/Elan456/fastquadtree/main/assets/interactive_v2_screenshot.png"
43
+ alt="Interactive Screenshot" align="right" width="420">
46
44
 
47
- [![PyPI Downloads](https://static.pepy.tech/personalized-badge/fastquadtree?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=BLUE&left_text=Total+Downloads)](https://pepy.tech/projects/fastquadtree)
45
+ Rust-optimized quadtree with a clean Python API
48
46
 
47
+ [![PyPI](https://img.shields.io/pypi/v/fastquadtree.svg)](https://pypi.org/project/fastquadtree/)
48
+ [![Python versions](https://img.shields.io/pypi/pyversions/fastquadtree.svg)](https://pypi.org/project/fastquadtree/)
49
+ [![Downloads](https://static.pepy.tech/personalized-badge/fastquadtree?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=BLUE&left_text=Total%20Downloads)](https://pepy.tech/projects/fastquadtree)
49
50
  [![Build](https://github.com/Elan456/fastquadtree/actions/workflows/release.yml/badge.svg)](https://github.com/Elan456/fastquadtree/actions/workflows/release.yml)
50
- [![Codecov](https://codecov.io/gh/Elan456/fastquadtree/branch/main/graph/badge.svg)](https://codecov.io/gh/Elan456/fastquadtree)
51
51
 
52
- [![Rust core via PyO3](https://img.shields.io/badge/Rust-core%20via%20PyO3-orange)](https://pyo3.rs/)
53
- [![Built with maturin](https://img.shields.io/badge/Built%20with-maturin-1f6feb)](https://www.maturin.rs/)
52
+ [![PyO3](https://img.shields.io/badge/Rust-core%20via%20PyO3-orange)](https://pyo3.rs/)
53
+ [![maturin](https://img.shields.io/badge/Built%20with-maturin-1f6feb)](https://www.maturin.rs/)
54
54
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
55
55
 
56
+ [![Docs](https://img.shields.io/badge/docs-online-brightgreen)](https://elan456.github.io/fastquadtree/)
57
+ [![Wheels](https://img.shields.io/pypi/wheel/fastquadtree.svg)](https://pypi.org/project/fastquadtree/#files)
58
+ [![Coverage](https://codecov.io/gh/Elan456/fastquadtree/branch/main/graph/badge.svg)](https://codecov.io/gh/Elan456/fastquadtree)
59
+ [![License: MIT](https://img.shields.io/pypi/l/fastquadtree.svg)](LICENSE)
56
60
 
61
+ <br clear="right"/>
57
62
 
58
- ![Interactive_V2_Screenshot](https://raw.githubusercontent.com/Elan456/fastquadtree/main/assets/interactive_v2_screenshot.png)
63
+ ## Why use fastquadtree
59
64
 
65
+ - Clean [Python API](https://elan456.github.io/fastquadtree/api/quadtree/) with modern typing hints
66
+ - The fastest quadtree Python package ([>10x faster](https://elan456.github.io/fastquadtree/benchmark/) than pyqtree)
67
+ - Prebuilt wheels for Windows, macOS, and Linux
68
+ - Support for [inserting bounding boxes](https://elan456.github.io/fastquadtree/api/rect_quadtree/) or points
69
+ - Fast KNN and range queries
70
+ - Optional object tracking for id ↔ object mapping
71
+ - [100% test coverage](https://codecov.io/gh/Elan456/fastquadtree) and CI on GitHub Actions
60
72
 
61
- Rust-optimized quadtree with a simple Python API.
73
+ ----
62
74
 
63
75
  👉 **Docs:** https://elan456.github.io/fastquadtree/
64
76
 
65
- - Python package: **`fastquadtree`**
66
- - Python 3.8
67
- - Import path: `from fastquadtree import QuadTree`
77
+ ## Examples
78
+ See examples of how fastquadtree can be used in the [runnables](https://elan456.github.io/fastquadtree/runnables/) section.
79
+
80
+
81
+ ## Install
82
+ ```bash
83
+ pip install fastquadtree
84
+ ```
85
+
86
+ ```python
87
+ from fastquadtree import QuadTree # Point handling
88
+ from fastquadtree import RectQuadTree # Bounding box handling
89
+ ```
68
90
 
69
91
  ## Benchmarks
70
92
 
@@ -89,28 +111,7 @@ fastquadtree **outperforms** all other quadtree Python packages, including the R
89
111
  | PyQtree | 1.492 | 0.263 | 1.755 | 1.00× |
90
112
  | quads | 1.407 | 0.484 | 1.890 | 0.93× |
91
113
 
92
- ### Benchmark Configuration
93
- | Parameter | Value |
94
- |---|---:|
95
- | Bounds | (0, 0, 1000, 1000) |
96
- | Max points per node | 128 |
97
- | Max depth | 16 |
98
- | Queries per experiment | 500 |
99
-
100
- See the [benchmark section](https://elan456.github.io/fastquadtree/benchmark/) for details.
101
-
102
- ## Install
103
-
104
- ```bash
105
- pip install fastquadtree
106
- ```
107
-
108
- If you are developing locally:
109
-
110
- ```bash
111
- # optimized dev install
112
- maturin develop --release
113
- ```
114
+ See the [benchmark section](https://elan456.github.io/fastquadtree/benchmark/) for details, including configurations, system info, and native vs shim benchmarks.
114
115
 
115
116
  ## Quickstart
116
117
  [See the quickstart guide](https://elan456.github.io/fastquadtree/quickstart/)
@@ -1,12 +1,13 @@
1
- fastquadtree-0.8.1.dist-info/METADATA,sha256=JHkAK_rP_q9R0JTgWv8OdKv6oDWB94A1XOr196UTK_g,8477
2
- fastquadtree-0.8.1.dist-info/WHEEL,sha256=cqfH6P_NujaeOc1olR46J5a7YgoxWJnrr5iZ1_DMqps,129
3
- fastquadtree-0.8.1.dist-info/licenses/LICENSE,sha256=pRuvcuqIMtEUBMgvP1Bc4fOHydzeuA61c6DQoQ1pb1w,1071
1
+ fastquadtree-0.9.1.dist-info/METADATA,sha256=ZUdCmtvzf7fHofYIKv0A6txQ78-ODxVkghW_3Qdpi8w,9088
2
+ fastquadtree-0.9.1.dist-info/WHEEL,sha256=cqfH6P_NujaeOc1olR46J5a7YgoxWJnrr5iZ1_DMqps,129
3
+ fastquadtree-0.9.1.dist-info/licenses/LICENSE,sha256=pRuvcuqIMtEUBMgvP1Bc4fOHydzeuA61c6DQoQ1pb1w,1071
4
4
  fastquadtree/__init__.py,sha256=rtkveNz7rScRasTRGu1yEqzeoJfLfreJNxg21orPL-U,195
5
5
  fastquadtree/_base_quadtree.py,sha256=MCXkrEnMqZmYLRAChVsjBu_R9n-bvclPmgmwTscZpzQ,8413
6
6
  fastquadtree/_bimap.py,sha256=7QBJ3QzEQq69PhKNA2W04N37i3-oNleEyb_qSXGSecw,3327
7
7
  fastquadtree/_item.py,sha256=0dxvqAMa94Zg-ZjYVMeZJt-irpafalrXph_Qeqp40AU,1348
8
- fastquadtree/_native.abi3.so,sha256=K7oryyJ77zZOS0NtGEmvMu_WyFll2u7O4nQ78ivBetg,465384
8
+ fastquadtree/_native.abi3.so,sha256=NVl0i8M0DDVWoYT5yqy1wUNaNhsd-i56g874FzsZ2cA,466880
9
9
  fastquadtree/point_quadtree.py,sha256=3bW4Apol-0TKSYF4IJ5KLbn9mhLEFSQT7P-rD9H6vuc,5583
10
10
  fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ fastquadtree/pyqtree.py,sha256=Q2b1Ixc9u4d6_YM6-40i3TSkIo4PxYQdoG96I6TC0A4,4725
11
12
  fastquadtree/rect_quadtree.py,sha256=fVjb5o8kl3s2FwuzpaaMeUV2Ni_h7uxjJNeWdJTNWws,3519
12
- fastquadtree-0.8.1.dist-info/RECORD,,
13
+ fastquadtree-0.9.1.dist-info/RECORD,,