Fix: .sel() now actually slices the uxgrid too, for UxDataArray and UxDataset - #1715
Open
Sevans711 wants to merge 3 commits into
Open
Fix: .sel() now actually slices the uxgrid too, for UxDataArray and UxDataset#1715Sevans711 wants to merge 3 commits into
.sel() now actually slices the uxgrid too, for UxDataArray and UxDataset#1715Sevans711 wants to merge 3 commits into
Conversation
(sel had docstrings before but they were the xarray docstrings, so they didn't say anything about uxarray-specific behaviors.)
Sevans711
requested review from
cmdupuis3,
dylannelson,
erogluorhan and
rajeeja
August 26, 2026 21:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1641
Overview
Adds implementations for
UxDataset.sel()andUxDataArray.sel()which actually slice the uxgrid too, ensuring the result's uxgrid and the result's data do not get out of synch. Followed the plan described in #1641, i.e., offload grid dimension indexing to.isel()(if there are coordinate labels for a grid dim, convert labels into indices first), and just utilize xarray's.sel()for non-grid dims.Adds regression tests (see
test_sel_indexes_grid(), which ensures the originally-reported bug is fixed, andtest_sel_uses_grid_dim_labels(), which ensures sel() is using the actual coordinate labels for grid dimensions if there is a corresponding coordinate value). Also adds a test to ensure sel() still works even for grid dimensions which are not part of the data.Tiny expansion of scope: fills out the docstring for the
_validate_indexersfunction. Aside from that, there is no expansion of scope, the changes here all relate to fixing the original bug.PR Checklist
General
Testing & Benchmarking
Documentation and Examples
docs/api.rst; internal (private) function names start with an underscore (_)AI Disclosure
AI Usage: GitHub Copilot's inline code suggestions, and probably some small discussions with Claude