Skip to content

Fixes for the updates-202606 migration (follow-up to #90 review) - #94

Merged
regislon merged 8 commits into
updates-202606from
fixes-pr90-review
Aug 24, 2026
Merged

regislon merged 8 commits into
updates-202606from
fixes-pr90-review

Conversation

@regislon

Copy link
Copy Markdown
Collaborator

Follow-up to the review comments on #90, as discussed there. All changes are confined to the h3ronpy crate (Python bindings) — nothing in crates/h3arrow is touched.

Fixes

  • cells_to_wkb_polygons returns large_binary again — geoarrow-array 0.8's WkbArray alias is GenericWkbArray<i32>; the function now uses LargeWkbArray (i64 offsets) like the other *_to_wkb_* functions, restoring the 0.22 output dtype and avoiding i32 offset overflow on > 2 GiB payloads.
  • WKB conversion errors raise Python exceptions instead of panicking — the ToWKB* error type is no longer Infallible, so the four .expect("wkbarray") calls became reachable panic paths. (You mentioned you had started on this one — feel free to drop commit 5d52ea4 in favor of your version.)
  • WKB output field is named "geometry" again (was "" after the extension_field() → to_field("", true) change).
  • rasterh3 0.11 → 0.12 — picks up the antimeridian and resolution-search fixes from 2026-06-26; compiles without code changes. (Same here — drop b3626ba if your version is further along.)
  • ContainmentMode is now hashable (hash, frozen on the pyclass) — it was unhashable in 0.22 as well; noticed while writing the containment-mode tests.

Tests added (tests/arrow/test_vector.py)

  • all four *_to_wkb_* functions return large_binary
  • the WKB output field is named geometry and carries the ARROW:extension:name = geoarrow.wkb metadata
  • wkb_to_cells: flatten/list-array consistency, per-geometry compact verified by round-tripping through uncompact, containment-mode count ordering, null entries preserved

Not addressed here (out of scope for the bindings crate)

  • Empty geometries → null entries (review point 2) lives in crates/h3arrow/src/array/from_geoarrow.rs (try_to_geometry() returning None for empty geometries) — left for you to decide whether to restore the empty-list behavior or document the new semantics.
  • New finding while writing the tests: wkb_to_cells(..., compact=True, flatten=True) fails with ValueError: heterogeneous resolution — the flatten path compacts the already per-geometry-compacted (mixed-resolution) cells a second time (from_geoarrow.rs, ToCellIndexArray::to_cellindexarray). This is pre-existing — 0.22.0 from PyPI fails identically — so not a regression from this migration. Documented as an xfail test for now.
  • The unused geozero dependency and the missing crates/h3arrow/CHANGES.md entry, for the same reason.

Verified locally on macOS arm64 / Python 3.12: cargo test --workspace, cargo clippy, cargo fmt --check, and the full pytest suite (50 passed, 1 xfailed).

🤖 Generated with Claude Code

regislon and others added 8 commits August 12, 2026 08:01
geoarrow-array 0.8's `WkbArray` is an alias for `GenericWkbArray<i32>`, so
the migration silently changed the output of cells_to_wkb_polygons from
large_binary to binary. This was inconsistent with the other *_to_wkb_*
functions (which kept <i64>) and would panic on i32 offset overflow for
WKB payloads over 2 GiB.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The ToWKB* error type changed from Infallible to a real error in the
geoarrow 0.8 migration, turning the pre-existing .expect("wkbarray")
calls into reachable panic paths. Convert them into Python exceptions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The migration replaced extension_field() with data_type().to_field("", true),
changing the arro3-visible field name from "geometry" to "".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Picks up the antimeridian and resolution-search fixes released on
2026-06-26, plus iterator perf improvements.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Allows using the enum as a dict key / in sets, as expected from a Python
enum. It was unhashable in 0.22 as well (eq without hash removes the
default __hash__).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- all *_to_wkb_* functions return large_binary (i64 offsets)
- WKB output field is named "geometry" and carries the geoarrow.wkb
  extension metadata
- wkb_to_cells: flatten/list consistency, per-geometry compact round-trip
  via uncompact, containment mode ordering, null entry preservation
- document the pre-existing compact+flatten 'heterogeneous resolution'
  failure (present in 0.22.0 as well) as xfail

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@keewis keewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this looks good to me, I just have some small nits.

Comment thread h3ronpy/src/vector.rs
Comment on lines +254 to +255
// LargeWkbArray (i64 offsets) to match the other WKB-producing functions and the
// pre-0.23 behavior, and to avoid i32 offset overflow on large outputs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you remove the comparison ("pre-0.23 behavior"), please? This kind of comment tends to age really badly, so I'd stick this in the changelog

Comment on lines +63 to +65
# regression test: with geoarrow-array 0.8, the `WkbArray` alias uses i32
# offsets. All WKB-producing functions must keep returning large_binary
# (i64 offsets) as in h3ronpy 0.22.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

on the other hand, this is fine (but quite possibly we don't need the "as in h3ronpy 0.22")

Comment on lines +112 to +113
reason="compact+flatten compacts the already per-geometry-compacted (mixed resolution) "
"cells a second time and fails with 'heterogeneous resolution'. Present in 0.22.0 as well.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
reason="compact+flatten compacts the already per-geometry-compacted (mixed resolution) "
"cells a second time and fails with 'heterogeneous resolution'. Present in 0.22.0 as well.",
reason=(
"compact+flatten compacts the already per-geometry-compacted (mixed resolution) "
"cells a second time and fails with 'heterogeneous resolution'. Present in 0.22.0 as well."
),

@nmandery nmandery left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good to me - thank you for the fixes.

@keewis keewis mentioned this pull request Aug 18, 2026
@regislon
regislon merged commit a8c1e29 into updates-202606 Aug 24, 2026
1 check passed
@keewis
keewis deleted the fixes-pr90-review branch August 24, 2026 12:58
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.

3 participants