You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix intersection bug and add Python 3.13 support (v0.7.0)
BREAKING CHANGES:
- Changed internal Real type from float to double to fix precision bug
- Binary serialization format changed (incompatible with v0.6.x)
- Updated pybind11 from v2.12.0 to v2.13.6
Bug Fix:
- Fixed critical bug where boxes with small gaps (< 1e-5) were incorrectly
reported as intersecting due to float32 precision loss
- Root cause: PRTree constructor and insert method were using py::array_t<float>
instead of py::array_t<Real>, causing float64 -> float32 conversion
- Example: boxes separated by 5.39e-06 would collapse to same float32 value
Changes:
- cpp/prtree.h: Changed 'using Real = float' to 'using Real = double'
- cpp/prtree.h: Updated PRTree constructor to use py::array_t<Real>
- cpp/prtree.h: Updated insert method to use py::array_t<Real>
- cpp/main.cc: Updated all pybind11 bindings to use py::array_t<double>
- third/pybind11: Updated submodule from v2.12.0 to v2.13.6
- setup.py: Bumped version to v0.7.0, added Python 3.13 support
- requirements.txt: Removed numpy<2.0 constraint for numpy 2.0 support
- .github/workflows/cibuildwheel.yml: Added Python 3.13 builds
- README.md: Added breaking changes notice and bug fix details
- tests/test_PRTree.py: Added comprehensive tests for:
- Disjoint boxes with small gaps (regression test)
- Touching boxes (closed interval semantics)
- Large magnitude coordinates
- Degenerate boxes
- Query vs batch_query consistency
All 121 tests pass.
Fixes issue reported by Matteo Lacki.
Co-Authored-By: atksh <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,20 @@ Note that cross-version compatibility is **NOT** guaranteed, so please reconstru
174
174
175
175
## New Features and Changes
176
176
177
+
### `python-prtree>=0.7.0`
178
+
179
+
**BREAKING CHANGES:**
180
+
181
+
-**Fixed critical intersection bug**: Boxes with small gaps (< 1e-5) were incorrectly reported as intersecting due to float32 precision loss. The internal `Real` type has been changed from `float` to `double` to preserve float64 precision from NumPy arrays.
182
+
-**Serialization format changed**: Binary files saved with previous versions are incompatible with 0.7.0+. You must rebuild and re-save your trees after upgrading.
183
+
-**Updated pybind11**: Upgraded from v2.12.0 to v2.13.6 for Python 3.13+ support.
184
+
-**Python 3.13 support**: Added official support for Python 3.13.
185
+
-**Improved test coverage**: Added comprehensive tests for edge cases including disjoint boxes with small gaps, touching boxes, large magnitude coordinates, and degenerate boxes.
186
+
187
+
**Bug Fix Details:**
188
+
189
+
The bug occurred when two bounding boxes were separated by a very small gap (e.g., 5.39e-06). When converted from float64 to float32, the values would collapse to the same float32 value, causing the intersection check to incorrectly report them as intersecting. This has been fixed by using double precision throughout the library.
190
+
177
191
### `python-prtree>=0.5.8`
178
192
179
193
- The insert method has been improved to select the node with the smallest mbb expansion.
0 commit comments