Skip to content

Commit ae51717

Browse files
authored
Fix to_polycollection exclude path: always cache antimeridian_face_indices (#1510)
* Fix to_polycollection exclude path: always cache antimeridian_face_indices Fixes #1507 When to_polycollection is called without a projection, antimeridian_face_indices was computed but never written to _poly_collection_cached_parameters, leaving the cache entry as None. dataarray.to_polycollection then called np.delete(data, None, axis=0), which became a hard IndexError in numpy 2.0 (previously a silent no-op or deprecation warning). Move the cache write to before the projection-only block so the entry is always populated regardless of whether a projection is supplied. * Restore both cache writes outside projection if-block PR #1454 accidentally moved both non_nan_polygon_indices and antimeridian_face_indices cache writes inside the projection check. Move them back out unconditionally, restoring the pre-#1454 behavior.
1 parent 1a51f7c commit ae51717

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

uxarray/grid/geometry.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,12 @@ def _grid_to_matplotlib_polycollection(
507507
does_not_contain_nan = ~np.isnan(shells_d).any(axis=(1, 2))
508508
non_nan_polygon_indices = np.where(does_not_contain_nan)[0]
509509

510-
grid._poly_collection_cached_parameters["non_nan_polygon_indices"] = (
511-
non_nan_polygon_indices
512-
)
513-
grid._poly_collection_cached_parameters["antimeridian_face_indices"] = (
514-
antimeridian_face_indices
515-
)
510+
grid._poly_collection_cached_parameters["non_nan_polygon_indices"] = (
511+
non_nan_polygon_indices
512+
)
513+
grid._poly_collection_cached_parameters["antimeridian_face_indices"] = (
514+
antimeridian_face_indices
515+
)
516516

517517
# Select which shells to use: projected or original
518518
if projected_polygon_shells is not None:

0 commit comments

Comments
 (0)