Fix: .sel() now actually slices the uxgrid too, for UxDataArray and UxDataset - #1715
Fix: .sel() now actually slices the uxgrid too, for UxDataArray and UxDataset#1715Sevans711 wants to merge 4 commits into
.sel() now actually slices the uxgrid too, for UxDataArray and UxDataset#1715Conversation
(sel had docstrings before but they were the xarray docstrings, so they didn't say anything about uxarray-specific behaviors.)
dylannelson
left a comment
There was a problem hiding this comment.
Ran it through some tests, got it to install and run cleanly on my end.
The ~70 line docstring seems like a bit much, but not a blocker.
I noticed the mix of comments like
(uncomment the next few lines after fixing #1713)
So I'll start taking a look at those too to get an idea for the bigger picture here, but it looks like you're planning ahead. Thanks!
|
Thank you for the review! Small follow-up:
It also felt a bit long to me too… though most of it is just a copy-paste of xarray's |
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