Skip to content

Fix NumPy 2.0 compatibility in simplify.py using 3D padding#2079

Merged
SandeepTuniki merged 1 commit into
masterfrom
fix-numpy-2.0-rdp
Jun 29, 2026
Merged

Fix NumPy 2.0 compatibility in simplify.py using 3D padding#2079
SandeepTuniki merged 1 commit into
masterfrom
fix-numpy-2.0-rdp

Conversation

@SandeepTuniki

@SandeepTuniki SandeepTuniki commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The rdp library calls np.cross() on 2D vectors, which fails with a ValueError in NumPy 2.0+. PR #2078 attempted to fix this by pinning numpy<=2.0.0, but it caused pandas to segfault in the CI due to binary incompatibilities.

As a workaround, I padded 2D coordinates to 3D ([x, y, 0.0]) before passing them to rdp.rdp , and stripped them back to 2D afterwards. Since np.cross is supported for 3D vectors in NumPy 2.0+, this should fix the issue.

I ran the failing tests locally to confirm that they're passing now.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the upper bound constraint on numpy in requirements.txt and updates the GeoJSON simplification script to pad 2D coordinates to 3D, avoiding NumPy 2.0+ errors in the rdp library. The reviewer suggests checking the coordinate dimensions first to ensure that existing 3D coordinates are not stripped of their altitude data.

Comment thread scripts/us_census/geojsons_low_res/simplify.py
@SandeepTuniki SandeepTuniki requested a review from ajaits June 29, 2026 15:41

@ajaits ajaits left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick fix!

@SandeepTuniki SandeepTuniki merged commit feefe98 into master Jun 29, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants