fastquadtree 0.5.1__cp38-abi3-win_amd64.whl → 0.6.0__cp38-abi3-win_amd64.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.
fastquadtree/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Iterable, Literal, Tuple, overload
3
+ from typing import Any, Literal, Tuple, overload
4
4
 
5
5
  from ._bimap import BiMap # type: ignore[attr-defined]
6
6
  from ._item import Item
@@ -103,37 +103,33 @@ class QuadTree:
103
103
  self._count += 1
104
104
  return id_
105
105
 
106
- def insert_many_points(self, points: Iterable[Point]) -> int:
106
+ def insert_many_points(self, points: list[Point]) -> int:
107
107
  """
108
108
  Bulk insert points with auto-assigned ids.
109
109
 
110
110
  Args:
111
- points: Iterable of (x, y) points.
111
+ points: List of (x, y) points.
112
112
 
113
113
  Returns:
114
- Number of points successfully inserted.
115
-
116
- Raises:
117
- ValueError: If any point is outside tree bounds.
114
+ The number of points inserted
118
115
  """
119
- ins = self._native.insert
120
- nid = self._next_id
121
- inserted = 0
122
- bx0, by0, bx1, by1 = self._bounds
123
- for xy in points:
124
- id_ = nid
125
- nid += 1
126
- if not ins(id_, xy):
127
- x, y = xy
128
- raise ValueError(
129
- f"Point ({x}, {y}) is outside bounds ({bx0}, {by0}, {bx1}, {by1})"
130
- )
131
- inserted += 1
132
- if self._items is not None:
133
- self._items.add(Item(id_, xy[0], xy[1], None))
134
- self._next_id = nid
135
- self._count += inserted
136
- return inserted
116
+ start_id = self._next_id
117
+ last_id = self._native.insert_many_points(start_id, points)
118
+
119
+ num_inserted = last_id - start_id + 1
120
+
121
+ if num_inserted < len(points):
122
+ raise ValueError("One or more points are outside tree bounds")
123
+
124
+ self._next_id = last_id + 1
125
+
126
+ # Update the item tracker if needed
127
+ if self._items is not None:
128
+ for i, id_ in enumerate(range(start_id, last_id + 1)):
129
+ x, y = points[i]
130
+ self._items.add(Item(id_, x, y, None))
131
+
132
+ return num_inserted
137
133
 
138
134
  def attach(self, id_: int, obj: Any) -> None:
139
135
  """
@@ -263,7 +259,7 @@ class QuadTree:
263
259
 
264
260
  if self._items is None:
265
261
  raise ValueError("Cannot return result as item with track_objects=False")
266
- id_, x, y = t
262
+ id_, _x, _y = t
267
263
  item = self._items.by_id(id_)
268
264
  if item is None:
269
265
  raise RuntimeError(
fastquadtree/__init__.pyi CHANGED
@@ -31,7 +31,6 @@ class QuadTree:
31
31
  # Inserts
32
32
  def insert(self, xy: Point, *, id_: int | None = ..., obj: Any = ...) -> int: ...
33
33
  def insert_many_points(self, points: Iterable[Point]) -> int: ...
34
- def insert_many(self, items: Iterable[tuple[Point, Any]]) -> int: ...
35
34
  def attach(self, id_: int, obj: Any) -> None: ...
36
35
 
37
36
  # Deletions
fastquadtree/_native.pyd CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastquadtree
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3 :: Only
6
6
  Classifier: Programming Language :: Rust
@@ -35,15 +35,14 @@ Project-URL: Issues, https://github.com/Elan456/fastquadtree/issues
35
35
  [![Wheels](https://img.shields.io/pypi/wheel/fastquadtree.svg)](https://pypi.org/project/fastquadtree/#files)
36
36
  [![License: MIT](https://img.shields.io/pypi/l/fastquadtree.svg)](LICENSE)
37
37
 
38
- [![Downloads total](https://static.pepy.tech/badge/fastquadtree)](https://pepy.tech/projects/fastquadtree)
39
- [![Downloads month](https://static.pepy.tech/badge/fastquadtree/month)](https://pepy.tech/projects/fastquadtree)
38
+ [![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)
40
39
 
41
40
  [![Build](https://github.com/Elan456/fastquadtree/actions/workflows/release.yml/badge.svg)](https://github.com/Elan456/fastquadtree/actions/workflows/ci.yml)
42
41
  [![Codecov](https://codecov.io/gh/Elan456/fastquadtree/branch/main/graph/badge.svg)](https://codecov.io/gh/Elan456/fastquadtree)
43
42
 
44
43
  [![Rust core via PyO3](https://img.shields.io/badge/Rust-core%20via%20PyO3-orange)](https://pyo3.rs/)
45
44
  [![Built with maturin](https://img.shields.io/badge/Built%20with-maturin-1f6feb)](https://www.maturin.rs/)
46
- [![Lint and format: Ruff](https://img.shields.io/badge/Lint%20and%20format-Ruff-46a758?logo=ruff&logoColor=white)](https://docs.astral.sh/ruff/)
45
+ [![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)
47
46
 
48
47
 
49
48
 
@@ -66,18 +65,27 @@ fastquadtree **outperforms** all other quadtree Python packages, including the R
66
65
  ![Throughput](https://raw.githubusercontent.com/Elan456/fastquadtree/main/assets/quadtree_bench_throughput.png)
67
66
 
68
67
  ### Summary (largest dataset, PyQtree baseline)
69
- - Points: **500,000**, Queries: **500**
68
+ - Points: **250,000**, Queries: **500**
70
69
  --------------------
71
- - Fastest total: **fastquadtree** at **1.591 s**
70
+ - Fastest total: **fastquadtree** at **0.120 s**
72
71
 
73
72
  | Library | Build (s) | Query (s) | Total (s) | Speed vs PyQtree |
74
73
  |---|---:|---:|---:|---:|
75
- | fastquadtree | 0.165 | 1.427 | 1.591 | 5.09× |
76
- | Rtree | 1.320 | 2.369 | 3.688 | 2.20× |
77
- | PyQtree | 2.687 | 5.415 | 8.102 | 1.00× |
78
- | nontree-QuadTree | 1.284 | 9.891 | 11.175 | 0.73× |
79
- | quads | 2.346 | 10.129 | 12.475 | 0.65× |
80
- | e-pyquadtree | 1.795 | 11.855 | 13.650 | 0.59× |
74
+ | fastquadtree | 0.031 | 0.089 | 0.120 | 14.64× |
75
+ | Shapely STRtree | 0.179 | 0.100 | 0.279 | 6.29× |
76
+ | nontree-QuadTree | 0.595 | 0.605 | 1.200 | 1.46× |
77
+ | Rtree | 0.961 | 0.300 | 1.261 | 1.39× |
78
+ | e-pyquadtree | 1.005 | 0.660 | 1.665 | 1.05× |
79
+ | PyQtree | 1.492 | 0.263 | 1.755 | 1.00× |
80
+ | quads | 1.407 | 0.484 | 1.890 | 0.93× |
81
+
82
+ #### Benchmark Configuration
83
+ | Parameter | Value |
84
+ |---|---:|
85
+ | Bounds | (0, 0, 1000, 1000) |
86
+ | Max points per node | 128 |
87
+ | Max depth | 16 |
88
+ | Queries per experiment | 500 |
81
89
 
82
90
  ## Install
83
91
 
@@ -281,7 +289,7 @@ MIT. See `LICENSE`.
281
289
 
282
290
  ## Acknowledgments
283
291
 
284
- * Python libraries compared: [PyQtree], [e-pyquadtree], [Rtree], [nontree], [quads]
292
+ * Python libraries compared: [PyQtree], [e-pyquadtree], [Rtree], [nontree], [quads], [Shapely]
285
293
  * Built with [PyO3] and [maturin]
286
294
 
287
295
  [PyQtree]: https://pypi.org/project/pyqtree/
@@ -290,4 +298,6 @@ MIT. See `LICENSE`.
290
298
  [maturin]: https://www.maturin.rs/
291
299
  [Rtree]: https://pypi.org/project/Rtree/
292
300
  [nontree]: https://pypi.org/project/nontree/
293
- [quads]: https://pypi.org/project/quads/
301
+ [quads]: https://pypi.org/project/quads/
302
+ [Shapely]: https://pypi.org/project/Shapely/
303
+
@@ -0,0 +1,10 @@
1
+ fastquadtree-0.6.0.dist-info/METADATA,sha256=NRMlg6YFAuT7fwSjEfV2F_r3Yw71JDwKibvRVPaQyHI,10746
2
+ fastquadtree-0.6.0.dist-info/WHEEL,sha256=7bfl5v0wbVhXZba613g0x-n2obNNfpQuN8I1cQ4oaU8,94
3
+ fastquadtree-0.6.0.dist-info/licenses/LICENSE,sha256=46IVFhoCIwMo-ocq4olyEB1eBvvtaKic5yGLeKXnDuc,1092
4
+ fastquadtree/__init__.py,sha256=o7zH6lOu2lTxMafl9FNVZiecM0KVxqhC3FNSRbpaaqY,12435
5
+ fastquadtree/__init__.pyi,sha256=_HGJ9lpIZ9-JTSfMKSn8aif_tu60m2vgOXR4d0uXnRY,2062
6
+ fastquadtree/_bimap.py,sha256=SPFFw9hWAVRKZVXyDGYFFNw4MLV8qUlOq8gDbLcTqkg,3402
7
+ fastquadtree/_item.py,sha256=p-ymnE9S-c8Lc00KhNKN9Pt4bd05nZ6g-DB8q8D9zYk,533
8
+ fastquadtree/_native.pyd,sha256=72nxQfcx-JZkSZM3Jm-r7qHbwrL6Rhd5lrvftuuioeQ,254464
9
+ fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ fastquadtree-0.6.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- fastquadtree-0.5.1.dist-info/METADATA,sha256=3tYPbCeIMK_f0U0lR1_oeKPagw3M00sPO2GYq6us-xs,10443
2
- fastquadtree-0.5.1.dist-info/WHEEL,sha256=7bfl5v0wbVhXZba613g0x-n2obNNfpQuN8I1cQ4oaU8,94
3
- fastquadtree-0.5.1.dist-info/licenses/LICENSE,sha256=46IVFhoCIwMo-ocq4olyEB1eBvvtaKic5yGLeKXnDuc,1092
4
- fastquadtree/__init__.py,sha256=NhKAMKyc9N6UV1BKpyF4ssGamLiZlwi-gqwx1znhDEw,12583
5
- fastquadtree/__init__.pyi,sha256=hoX8-dibrH3Q9kv8M-h0Tac0BsJAoh1VYMd84vayhDE,2137
6
- fastquadtree/_bimap.py,sha256=SPFFw9hWAVRKZVXyDGYFFNw4MLV8qUlOq8gDbLcTqkg,3402
7
- fastquadtree/_item.py,sha256=p-ymnE9S-c8Lc00KhNKN9Pt4bd05nZ6g-DB8q8D9zYk,533
8
- fastquadtree/_native.pyd,sha256=Wz9Z_lSFp6JCgOY5gCYeHl4RwzgCyoyB-ZAgvoWVVhA,247808
9
- fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- fastquadtree-0.5.1.dist-info/RECORD,,