You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UxDataArray.isel() on edge-centered data crashes with confusing KeyError: No variable named '_subgrid_edge_indices'... if connectivity isn't populated #1758
Calling UxDataArray.isel(n_face=...) or .isel(n_node=...) on edge-centered data crashes with a very confusing error (see title). I suspect this is related to the lines in uxarray.grid.slice._slice_face_indices commented as "Only slice edge dimension if we have the face edge connectivity", which hide the ds["_subgrid_edge_indices"] = xr.DataArray(edge_indices, dims=["n_edge"]) inside a check of if "face_edge_connectivity" in ds, and when that check gives False it silently does something else instead of crashing or raising a warning.
This problem currently only affects UxDataArray, not also UxDataset, because UxDataset simply ignores the command to slice by anything (see #1713) in these cases.
What did you expect to happen?
I expected a clearer error message telling me why I can't do this, or suggesting that I should call arr.uxgrid.face_edge_connectivity to populate the connectivity and then try again, or for the connectivity to just be automatically populated at this stage because it was required for an operation I was attempting (most/all other uxarray grid vars get populated automatically as soon as they are needed…).
Can you provide a MCVE to repoduce the bug?
importuxarrayasuxarr=ux.tutorial.open_dataset('quad-hexagon-random-edge')['random_data_edge']
arr.isel(n_face=0) # crashesarr.isel(n_node=0) # crashes# but, if running the following before calling isel():arr.uxgrid.face_edge_connectivity# then the isel() commands do not crash:arr.isel(n_face=0)
arr.isel(n_node=0)
It is probably reasonable to just populate face_edge_connectivity in this case, now that the connectivity is much faster to compute (see, e.g., #1560 (comment)) compared to when this isel() routine was initially introduced. If connectivity was slow to compute it might be a different story, but since it is relatively fast (e.g. just a few seconds even for 3.75km MPAS grid) I suspect the user experience would be better if this just gets handled automatically.
Activity
Sevans711 commentedon Nov 3, 2026
It is probably reasonable to just populate face_edge_connectivity in this case, now that the connectivity is much faster to compute (see, e.g., #1560 (comment)) compared to when this isel() routine was initially introduced. If connectivity was slow to compute it might be a different story, but since it is relatively fast (e.g. just a few seconds even for 3.75km MPAS grid) I suspect the user experience would be better if this just gets handled automatically.