Repository navigation
Conversation
|
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. |
Collaborator
|
Thanks for the PR! We'll go with #11965, which the issue author had announced in the issue. Going through |
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.
Description
median()on datetime64 data callednp.median, which adds values and fails for datetime64. BecauseDataset.median()reduces every variable, one datetime variable made the whole call fail.For datetime64 (numpy dtype) inputs, the median now goes through the 0.5 quantile (
nputils.nanquantile, orquantilewhenskipna=False). That keeps the input dtype and skips NaT by default, the same asmean()on datetimes. Other dtypes take the existing path.Testing
test_datetime_median(even and single-value cases, NaT with default /skipna=True/skipna=False) andTestDataset::test_median_datetime. Both fail on main with the numpy add error and pass with this change.pytest xarray/tests/test_duck_array_ops.py xarray/tests/test_dataset.py xarray/tests/test_dataarray.py: 1744 passed, 753 skipped, 2 xfailed, 2 xpassed (numpy 2.5.5, pandas 3.1.2; dask was not installed locally, so the dask variants were skipped).Checklist
median()raises on datetime64 data and breaksDataset.median()#11964whats-new.rstAI Disclosure
Tools: Codex (first draft of the fix and tests, which I then trimmed and changed so NaT is skipped by default).