Skip to content

Accept read-only vertex and ring arrays - #44

Open
antonsoo wants to merge 2 commits into
skogler:mainfrom
antonsoo:fix/readonly-input-arrays
Open

antonsoo wants to merge 2 commits into
skogler:mainfrom
antonsoo:fix/readonly-input-arrays

Conversation

@antonsoo

Copy link
Copy Markdown

Make the input arrays' element types const. The triangulation code only reads the vertices and ring boundaries, but their current nanobind types require writable storage. Valid read-only arrays, including geometry loaded with np.load(..., mmap_mode="r"), therefore raise TypeError.

Both input aliases now use nb::ndarray<const T, ...>, following nanobind's read-only array convention. Shapes, supported numeric types, strided access and the returned uint32 indices stay the same.

Add 12 regressions covering read-only vertices, ring boundaries, or both, across all four coordinate dtypes. All 25 regular tests pass on Python 3.9/NumPy 1.26 and Python 3.12/NumPy 2.5, built with nanobind 2.9.2; the 12 free-threading tests are skipped in these interpreters.

An additional Natural Earth geometry audit restores all 320 failing read-only configurations, including 32 memory-mapped cache cases. Independent area and triangle-union checks pass, and all 96 writable controls keep identical indices. An extra Mypy check reports the same existing missing __version__ declaration on base and head.

This branch has not been deployed

No deployments
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.

1 participant