is_pentagon() is broken for ISEA aperture-7 grids — undercounts at resolution 1, hard errors at resolution >= 2
Defect
R/hex_topology.R:58-63:
pentagon_ids <- cpp_quad_ij_to_cell(
quad = 0:11, i = rep(0, 12), j = rep(0, 12),
resolution = res, aperture = ap
)
cell_id %in% pentagon_ids
Reproduction
Verified by running is_pentagon() across all cells from grid_global() at aperture 3/4/7, resolutions 1-3:
- Aperture 3 and 4: correctly report 12 pentagons at every resolution tested.
- Aperture 7, resolution 1: reports only 9 pentagons instead of 12. The candidate IDs from
cpp_quad_ij_to_cell(0:11, 0, 0, res=1, ap=7) are 31 32 113 194 275 356 437 518 599 680 761 842, but the valid cell-ID range for that grid is only 30-789 (95 cells total) — several candidate IDs fall outside the real range, so %in% silently fails to match them.
- Aperture 7, resolution 2: throws
Error: !anyNA(x) is not TRUE.
- Aperture 7, resolution 3: throws
Error: cell_id must be a finite value in [1, 12252] for resolution 3, aperture 7.
For any aperture-7 ISEA grid at resolution >= 2, is_pentagon() is completely unusable (hard error); at resolution 1 it silently gives a wrong answer.
Impact
tests/testthat/test-topology.R only asserts the pentagon count for H3 grids (is_pentagon detects 12 pentagons for H3); there is no equivalent ISEA assertion, so this went uncaught.
Fix
The candidate-pentagon-ID computation needs to account for aperture-7's actual quad/i/j-to-cell numbering at each resolution rather than assuming (quad, 0, 0) maps directly for every aperture.
is_pentagon()is broken for ISEA aperture-7 grids — undercounts at resolution 1, hard errors at resolution >= 2Defect
R/hex_topology.R:58-63:Reproduction
Verified by running
is_pentagon()across all cells fromgrid_global()at aperture 3/4/7, resolutions 1-3:cpp_quad_ij_to_cell(0:11, 0, 0, res=1, ap=7)are31 32 113 194 275 356 437 518 599 680 761 842, but the valid cell-ID range for that grid is only30-789(95 cells total) — several candidate IDs fall outside the real range, so%in%silently fails to match them.Error: !anyNA(x) is not TRUE.Error: cell_id must be a finite value in [1, 12252] for resolution 3, aperture 7.For any aperture-7 ISEA grid at resolution >= 2,
is_pentagon()is completely unusable (hard error); at resolution 1 it silently gives a wrong answer.Impact
tests/testthat/test-topology.Ronly asserts the pentagon count for H3 grids (is_pentagon detects 12 pentagons for H3); there is no equivalent ISEA assertion, so this went uncaught.Fix
The candidate-pentagon-ID computation needs to account for aperture-7's actual quad/i/j-to-cell numbering at each resolution rather than assuming
(quad, 0, 0)maps directly for every aperture.