Repository navigation
Fix isel() crashes for edge-centered data if face_edge_connectivity isn't populated - #1875
Conversation
(also fixes a tiny warning in the test suite about "\(" escape character; should have used r-string instead of default string)
ASV BenchmarkingBenchmark Comparison ResultsBenchmarks that have improved:
Benchmarks that have stayed the same:
Benchmarks that have got worse:
|
|
Probably off-topic, but this logic is 😬 . Surely there's a better way? counter = 0 # (count up during loop to make sure nothing is skipped unexpectedly)
for method in "isel", "sel":
for dataset in [ds_face, ds_node, ds_edge]:
for grid_dim in ("n_face", "n_edge", "n_node"):
for to_array in [False, True]:
counter += 1
obj = _as_array(dataset) if to_array else dataset |
cmdupuis3
left a comment
There was a problem hiding this comment.
This crash still happens with subset accessors, but I'll consider that out-of-scope.
Thank you for the review! I agree it should be out-of-scope for this PR, though I've opened #1888 so that it doesn't get forgotten after this PR merges. |
rajeeja
left a comment
There was a problem hiding this comment.
Approving. da.subset.bounding_box and da.subset.nearest_neighbor on edge data still raise the same KeyError because they call _slice_from_grid directly, so building face_edge_connectivity there or in slice.py would cover every caller (worth noting on #1888). Optional: the bare self.uxgrid.face_edge_connectivity line works only through its side effect, so a named variable would make that clearer.
Closes #1758
Overview
Populates
self.uxgrid.face_edge_connectivityexplicitly inside UxDataset.isel() and UxDataArray.isel() when there is edge centered data, just before callingself.uxgrid.isel(), so that uxgrid.isel() will actually populateuxgrid._ds["_subgrid_edge_indices"]which is needed later in the edge-centered case. This addresses the root cause of #1758, without altering any behavior for non-edge-centered data (for which isel() was working just fine).Uncommented the relevant pieces of test_indexing.py, which should provide sufficient test coverage for these changes. I also confirmed the MCVE in the issue report no longer crashes.
Tiny expansion of scope: fixes warning from test_indexing.py about the
\(escape character, by swapping to an r-string instead of default string forMATCH_ERRMSG_2.PR Checklist
General
Testing & Benchmarking
Documentation and Examples
docs/api.rst; internal (private) function names start with an underscore (_)AI Disclosure
AI Usage: just GitHub Copilot's inline code suggestions