fastquadtree 1.2.0__cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl → 1.2.1__cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.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.
Potentially problematic release.
This version of fastquadtree might be problematic. Click here for more details.
- fastquadtree/_base_quadtree.py +112 -0
- fastquadtree/_native.abi3.so +0 -0
- fastquadtree/point_quadtree.py +7 -0
- fastquadtree/rect_quadtree.py +7 -0
- {fastquadtree-1.2.0.dist-info → fastquadtree-1.2.1.dist-info}/METADATA +1 -1
- fastquadtree-1.2.1.dist-info/RECORD +13 -0
- fastquadtree-1.2.0.dist-info/RECORD +0 -13
- {fastquadtree-1.2.0.dist-info → fastquadtree-1.2.1.dist-info}/WHEEL +0 -0
- {fastquadtree-1.2.0.dist-info → fastquadtree-1.2.1.dist-info}/licenses/LICENSE +0 -0
fastquadtree/_base_quadtree.py
CHANGED
|
@@ -94,6 +94,12 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
94
94
|
|
|
95
95
|
Returns:
|
|
96
96
|
Includes a binary 'core' key for the native engine state, plus other metadata such as bounds and capacity and the obj store if tracking is enabled.
|
|
97
|
+
|
|
98
|
+
Example:
|
|
99
|
+
```python
|
|
100
|
+
state = qt.to_dict()
|
|
101
|
+
assert "core" in state and "bounds" in state
|
|
102
|
+
```
|
|
97
103
|
"""
|
|
98
104
|
|
|
99
105
|
core_bytes = self._native.to_bytes()
|
|
@@ -115,6 +121,13 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
115
121
|
|
|
116
122
|
Returns:
|
|
117
123
|
Bytes representing the serialized quadtree. Can be saved as a file or loaded with `from_bytes()`.
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
```python
|
|
127
|
+
blob = qt.to_bytes()
|
|
128
|
+
with open("tree.fqt", "wb") as f:
|
|
129
|
+
f.write(blob)
|
|
130
|
+
```
|
|
118
131
|
"""
|
|
119
132
|
return pickle.dumps(self.to_dict())
|
|
120
133
|
|
|
@@ -128,6 +141,13 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
128
141
|
|
|
129
142
|
Returns:
|
|
130
143
|
A new quadtree instance with the same state as when serialized.
|
|
144
|
+
|
|
145
|
+
Example:
|
|
146
|
+
```python
|
|
147
|
+
blob = qt.to_bytes()
|
|
148
|
+
qt2 = type(qt).from_bytes(blob)
|
|
149
|
+
assert qt2.count_items() == qt.count_items()
|
|
150
|
+
```
|
|
131
151
|
"""
|
|
132
152
|
in_dict = pickle.loads(data)
|
|
133
153
|
core_bytes = in_dict["core"]
|
|
@@ -174,6 +194,13 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
174
194
|
|
|
175
195
|
Raises:
|
|
176
196
|
ValueError: If geometry is outside the tree bounds.
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
```python
|
|
200
|
+
id0 = point_qt.insert((10.0, 20.0)) # for point trees
|
|
201
|
+
id1 = rect_qt.insert((0.0, 0.0, 5.0, 5.0), obj="box") # for rect trees
|
|
202
|
+
assert isinstance(id0, int) and isinstance(id1, int)
|
|
203
|
+
```
|
|
177
204
|
"""
|
|
178
205
|
if self._store is not None:
|
|
179
206
|
# Reuse a dense free slot if available, else append
|
|
@@ -219,6 +246,17 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
219
246
|
|
|
220
247
|
Raises:
|
|
221
248
|
ValueError: If any geometry is outside bounds.
|
|
249
|
+
|
|
250
|
+
Example:
|
|
251
|
+
```python
|
|
252
|
+
n = qt.insert_many([(1.0, 1.0), (2.0, 2.0)])
|
|
253
|
+
assert n == 2
|
|
254
|
+
|
|
255
|
+
import numpy as np
|
|
256
|
+
arr = np.array([[3.0, 3.0], [4.0, 4.0]], dtype=np.float32)
|
|
257
|
+
n2 = qt.insert_many(arr)
|
|
258
|
+
assert n2 == 2
|
|
259
|
+
```
|
|
222
260
|
"""
|
|
223
261
|
if type(geoms) is list and len(geoms) == 0:
|
|
224
262
|
return 0
|
|
@@ -283,8 +321,19 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
283
321
|
"""
|
|
284
322
|
Delete an item by id and exact geometry.
|
|
285
323
|
|
|
324
|
+
Args:
|
|
325
|
+
id_: The id of the item to delete.
|
|
326
|
+
geom: The geometry of the item to delete.
|
|
327
|
+
|
|
286
328
|
Returns:
|
|
287
329
|
True if the item was found and deleted.
|
|
330
|
+
|
|
331
|
+
Example:
|
|
332
|
+
```python
|
|
333
|
+
i = qt.insert((1.0, 2.0))
|
|
334
|
+
ok = qt.delete(i, (1.0, 2.0))
|
|
335
|
+
assert ok is True
|
|
336
|
+
```
|
|
288
337
|
"""
|
|
289
338
|
deleted = self._native.delete(id_, geom)
|
|
290
339
|
if deleted:
|
|
@@ -297,6 +346,17 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
297
346
|
"""
|
|
298
347
|
Attach or replace the Python object for an existing id.
|
|
299
348
|
Tracking must be enabled.
|
|
349
|
+
|
|
350
|
+
Args:
|
|
351
|
+
id_: The id of the item to attach the object to.
|
|
352
|
+
obj: The Python object to attach.
|
|
353
|
+
|
|
354
|
+
Example:
|
|
355
|
+
```python
|
|
356
|
+
i = qt.insert((2.0, 3.0), obj=None)
|
|
357
|
+
qt.attach(i, {"meta": 123})
|
|
358
|
+
assert qt.get(i) == {"meta": 123}
|
|
359
|
+
```
|
|
300
360
|
"""
|
|
301
361
|
if self._store is None:
|
|
302
362
|
raise ValueError("Cannot attach objects when track_objects=False")
|
|
@@ -309,6 +369,16 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
309
369
|
def delete_by_object(self, obj: Any) -> bool:
|
|
310
370
|
"""
|
|
311
371
|
Delete an item by Python object identity. Tracking must be enabled.
|
|
372
|
+
|
|
373
|
+
Args:
|
|
374
|
+
obj: The Python object to delete.
|
|
375
|
+
|
|
376
|
+
Example:
|
|
377
|
+
```python
|
|
378
|
+
i = qt.insert((3.0, 4.0), obj="tag")
|
|
379
|
+
ok = qt.delete_by_object("tag")
|
|
380
|
+
assert ok is True
|
|
381
|
+
```
|
|
312
382
|
"""
|
|
313
383
|
if self._store is None:
|
|
314
384
|
raise ValueError("Cannot delete by object when track_objects=False")
|
|
@@ -323,6 +393,13 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
323
393
|
|
|
324
394
|
If tracking is enabled, the id -> object mapping is also cleared.
|
|
325
395
|
The ids are reset to start at zero again.
|
|
396
|
+
|
|
397
|
+
Example:
|
|
398
|
+
```python
|
|
399
|
+
_ = qt.insert((5.0, 6.0))
|
|
400
|
+
qt.clear()
|
|
401
|
+
assert qt.count_items() == 0 and len(qt) == 0
|
|
402
|
+
```
|
|
326
403
|
"""
|
|
327
404
|
self._native = self._new_native(self._bounds, self._capacity, self._max_depth)
|
|
328
405
|
self._count = 0
|
|
@@ -333,6 +410,14 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
333
410
|
def get_all_objects(self) -> list[Any]:
|
|
334
411
|
"""
|
|
335
412
|
Return all tracked Python objects in the tree.
|
|
413
|
+
|
|
414
|
+
Example:
|
|
415
|
+
```python
|
|
416
|
+
_ = qt.insert((7.0, 8.0), obj="a")
|
|
417
|
+
_ = qt.insert((9.0, 1.0), obj="b")
|
|
418
|
+
objs = qt.get_all_objects()
|
|
419
|
+
assert set(objs) == {"a", "b"}
|
|
420
|
+
```
|
|
336
421
|
"""
|
|
337
422
|
if self._store is None:
|
|
338
423
|
raise ValueError("Cannot get objects when track_objects=False")
|
|
@@ -341,6 +426,13 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
341
426
|
def get_all_items(self) -> list[ItemType]:
|
|
342
427
|
"""
|
|
343
428
|
Return all Item wrappers in the tree.
|
|
429
|
+
|
|
430
|
+
Example:
|
|
431
|
+
```python
|
|
432
|
+
_ = qt.insert((1.0, 1.0), obj=None)
|
|
433
|
+
items = qt.get_all_items()
|
|
434
|
+
assert hasattr(items[0], "id_") and hasattr(items[0], "geom")
|
|
435
|
+
```
|
|
344
436
|
"""
|
|
345
437
|
if self._store is None:
|
|
346
438
|
raise ValueError("Cannot get items when track_objects=False")
|
|
@@ -349,12 +441,25 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
349
441
|
def get_all_node_boundaries(self) -> list[Bounds]:
|
|
350
442
|
"""
|
|
351
443
|
Return all node boundaries in the tree. Useful for visualization.
|
|
444
|
+
|
|
445
|
+
Example:
|
|
446
|
+
```python
|
|
447
|
+
bounds = qt.get_all_node_boundaries()
|
|
448
|
+
assert isinstance(bounds, list)
|
|
449
|
+
```
|
|
352
450
|
"""
|
|
353
451
|
return self._native.get_all_node_boundaries()
|
|
354
452
|
|
|
355
453
|
def get(self, id_: int) -> Any | None:
|
|
356
454
|
"""
|
|
357
455
|
Return the object associated with id, if tracking is enabled.
|
|
456
|
+
|
|
457
|
+
Example:
|
|
458
|
+
```python
|
|
459
|
+
i = qt.insert((1.0, 2.0), obj={"k": "v"})
|
|
460
|
+
obj = qt.get(i)
|
|
461
|
+
assert obj == {"k": "v"}
|
|
462
|
+
```
|
|
358
463
|
"""
|
|
359
464
|
if self._store is None:
|
|
360
465
|
raise ValueError("Cannot get objects when track_objects=False")
|
|
@@ -364,6 +469,13 @@ class _BaseQuadTree(Generic[G, HitT, ItemType], ABC):
|
|
|
364
469
|
def count_items(self) -> int:
|
|
365
470
|
"""
|
|
366
471
|
Return the number of items currently in the tree (native count).
|
|
472
|
+
|
|
473
|
+
Example:
|
|
474
|
+
```python
|
|
475
|
+
before = qt.count_items()
|
|
476
|
+
_ = qt.insert((2.0, 2.0))
|
|
477
|
+
assert qt.count_items() == before + 1
|
|
478
|
+
```
|
|
367
479
|
"""
|
|
368
480
|
return self._native.count_items()
|
|
369
481
|
|
fastquadtree/_native.abi3.so
CHANGED
|
Binary file
|
fastquadtree/point_quadtree.py
CHANGED
|
@@ -80,6 +80,13 @@ class QuadTree(_BaseQuadTree[Point, _IdCoord, PointItem]):
|
|
|
80
80
|
Returns:
|
|
81
81
|
If as_items is False: list of (id, x, y) tuples.
|
|
82
82
|
If as_items is True: list of Item objects.
|
|
83
|
+
|
|
84
|
+
Example:
|
|
85
|
+
```python
|
|
86
|
+
results = qt.query((10.0, 10.0, 20.0, 20.0), as_items=True)
|
|
87
|
+
for item in results:
|
|
88
|
+
print(f"Found point id={item.id_} at {item.geom} with obj={item.obj}")
|
|
89
|
+
```
|
|
83
90
|
"""
|
|
84
91
|
if not as_items:
|
|
85
92
|
return self._native.query(rect)
|
fastquadtree/rect_quadtree.py
CHANGED
|
@@ -81,6 +81,13 @@ class RectQuadTree(_BaseQuadTree[Bounds, _IdRect, RectItem]):
|
|
|
81
81
|
Returns:
|
|
82
82
|
If as_items is False: list of (id, x0, y0, x1, y1) tuples.
|
|
83
83
|
If as_items is True: list of Item objects.
|
|
84
|
+
|
|
85
|
+
Example:
|
|
86
|
+
```python
|
|
87
|
+
results = rqt.query((10.0, 10.0, 20.0, 20.0), as_items=True)
|
|
88
|
+
for item in results:
|
|
89
|
+
print(f"Found rect id={item.id_} at {item.geom} with obj={item.obj}")
|
|
90
|
+
```
|
|
84
91
|
"""
|
|
85
92
|
if not as_items:
|
|
86
93
|
return self._native.query(rect)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
fastquadtree-1.2.1.dist-info/METADATA,sha256=IYzvJNOV07j4qtOFQqryt15YjrnuWrSjJpK0NUDe-1E,9614
|
|
2
|
+
fastquadtree-1.2.1.dist-info/WHEEL,sha256=xBqaWU3Z-cfW-EFy0ENuEqxgXZXkIHUBkA1cT6FlqGM,127
|
|
3
|
+
fastquadtree-1.2.1.dist-info/licenses/LICENSE,sha256=pRuvcuqIMtEUBMgvP1Bc4fOHydzeuA61c6DQoQ1pb1w,1071
|
|
4
|
+
fastquadtree/__init__.py,sha256=rtkveNz7rScRasTRGu1yEqzeoJfLfreJNxg21orPL-U,195
|
|
5
|
+
fastquadtree/_base_quadtree.py,sha256=NhUkMulVa2ItCtx5rEnE_asHY3aGN0XxG6m-AYJk7CE,15091
|
|
6
|
+
fastquadtree/_item.py,sha256=EDS3nJHdVtjDsuTqTZKGTZH8iWJIQ-TKxLXqvMScNPA,2405
|
|
7
|
+
fastquadtree/_native.abi3.so,sha256=MkRrcW6ZJwhRQzl7OXguY7nk2T_CsycgLC22C2G-p0I,556604
|
|
8
|
+
fastquadtree/_obj_store.py,sha256=HeYFGUPYhvxBzL7Js0g0jsIxflpZS6RsXNk50rGeNlA,6522
|
|
9
|
+
fastquadtree/point_quadtree.py,sha256=BM6mxw2pSmAKkOgXnosREfC6WOXCgEYNeQDlvnlEbKQ,5945
|
|
10
|
+
fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
fastquadtree/pyqtree.py,sha256=2Khh1gCPalD4z0gb3EmqtzMoga08E9BkB0j5bwkiRPU,6076
|
|
12
|
+
fastquadtree/rect_quadtree.py,sha256=82IygiEmJ4JdA6LBDXq288cs9VfS3LpdJdkjCPcYCKM,3807
|
|
13
|
+
fastquadtree-1.2.1.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
fastquadtree-1.2.0.dist-info/METADATA,sha256=MUUv_93xtLD1Vbsm3t0JelXhuKt0VP1OmFlkQPcioHU,9614
|
|
2
|
-
fastquadtree-1.2.0.dist-info/WHEEL,sha256=xBqaWU3Z-cfW-EFy0ENuEqxgXZXkIHUBkA1cT6FlqGM,127
|
|
3
|
-
fastquadtree-1.2.0.dist-info/licenses/LICENSE,sha256=pRuvcuqIMtEUBMgvP1Bc4fOHydzeuA61c6DQoQ1pb1w,1071
|
|
4
|
-
fastquadtree/__init__.py,sha256=rtkveNz7rScRasTRGu1yEqzeoJfLfreJNxg21orPL-U,195
|
|
5
|
-
fastquadtree/_base_quadtree.py,sha256=ukiCKjsOPmnrkkKNLNJS5ad0X2HURYAWp9W60pk-c9Q,12045
|
|
6
|
-
fastquadtree/_item.py,sha256=EDS3nJHdVtjDsuTqTZKGTZH8iWJIQ-TKxLXqvMScNPA,2405
|
|
7
|
-
fastquadtree/_native.abi3.so,sha256=CVib-xgwo5sbXSJ5ypr25JmZ8u3reVrnivgamFeN-eM,556572
|
|
8
|
-
fastquadtree/_obj_store.py,sha256=HeYFGUPYhvxBzL7Js0g0jsIxflpZS6RsXNk50rGeNlA,6522
|
|
9
|
-
fastquadtree/point_quadtree.py,sha256=5ic-ZPq2AC20f9GkunKQAoH-W_doRFePOlJwqhST0FI,5697
|
|
10
|
-
fastquadtree/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
fastquadtree/pyqtree.py,sha256=2Khh1gCPalD4z0gb3EmqtzMoga08E9BkB0j5bwkiRPU,6076
|
|
12
|
-
fastquadtree/rect_quadtree.py,sha256=9JXqvh9WZGy7ZcfbXIRCWUf8oYpQz2QLB39f6XdP7u8,3559
|
|
13
|
-
fastquadtree-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|