drop_vars; deprecate drop for variables#3475
Conversation
|
What do you think about this alternative?
(I'm not really sure which is best, to be honest. But keeping down churn does seem like a good idea, if possible.) |
|
Yes, that sounds reasonable—I think we move documentation and internal usages to Maybe at last a case for |
|
Updated! I used |
|
@crusaderky let me know if you know off-hand why the |
Would |
I think either is reasonable. |
|
I wanted a name that is reminiscent of "sel" in some way.
…On Wed, Nov 6, 2019 at 7:14 AM Deepak Cherian ***@***.***> wrote:
Add drop_sel for dropping labels
Would drop_labels be better?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3475?email_source=notifications&email_token=AAJJFVVMPYUZS37B4BW2C43QSLNOPA5CNFSM4JHQAN7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDG4BNQ#issuecomment-550355126>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJJFVQKLRALMGU5ALWKWVLQSLNOPANCNFSM4JHQAN7A>
.
|
|
👍 |
|
This is ready to go! As a reminder, we have |
dcherian
left a comment
There was a problem hiding this comment.
LGTM. just some minor doc comments
xarray/core/dataset.py
Outdated
| dropped : Dataset | ||
|
|
||
| """ | ||
| if isinstance(names, str) or not isinstance(names, Iterable): |
There was a problem hiding this comment.
not sure if this should be isinstance(names, str) or is_scalar(names)?
There was a problem hiding this comment.
Good spot; I've changed this. But had to keep or not isinstance(names, Iterable): for mypy
@crusaderky as the resident expert, lmk if you have any thoughts on this.
|
Going to merge given @dcherian 's approval, any other follow-ups I can address in another PR |
…tests * upstream/master: drop_vars; deprecate drop for variables (pydata#3475) uamiv test using only raw uamiv variables (pydata#3485) Optimize dask array equality checks. (pydata#3453)
| - :py:meth:`Dataset.drop_sel` & :py:meth:`DataArray.drop_sel` have been added for dropping labels. | ||
| :py:meth:`Dataset.drop_vars` & :py:meth:`DataArray.drop_vars` have been added for | ||
| dropping variables (including coordinates). The existing ``drop`` methods remain as a backward compatible | ||
| option for dropping either lables or variables, but using the more specific methods is encouraged. |
|
Thank you @max-sixty, and @dcherian for reviewing! |
* upstream/master: (27 commits) drop_vars; deprecate drop for variables (pydata#3475) uamiv test using only raw uamiv variables (pydata#3485) Optimize dask array equality checks. (pydata#3453) Propagate indexes in DataArray binary operations. (pydata#3481) python 3.8 tests (pydata#3477) __dask_tokenize__ (pydata#3446) Type check sentinel values (pydata#3472) Fix typo in docstring (pydata#3474) fix test suite warnings re `drop` (pydata#3460) Fix integrate docs (pydata#3469) Fix leap year condition in monthly means example (pydata#3464) Hypothesis tests for roundtrip to & from pandas (pydata#3285) unpin cftime (pydata#3463) Cleanup whatsnew (pydata#3462) enable xr.ALL_DIMS in xr.dot (pydata#3424) Merge stable into master (pydata#3457) upgrade black verison to 19.10b0 (pydata#3456) Remove outdated code related to compatibility with netcdftime (pydata#3450) Remove deprecated behavior from dataset.drop docstring (pydata#3451) jupyterlab dark theme (pydata#3443) ...
* upstream/master: add missing pint integration tests (pydata#3508) DOC: update bottleneck repo url (pydata#3507) add drop_sel, drop_vars, map to api.rst (pydata#3506) remove syntax warning (pydata#3505) Dataset.map, GroupBy.map, Resample.map (pydata#3459) tests for datasets with units (pydata#3447) fix pandas-dev tests (pydata#3491) unpin pseudonetcdf (pydata#3496) whatsnew corrections (pydata#3494) drop_vars; deprecate drop for variables (pydata#3475) uamiv test using only raw uamiv variables (pydata#3485) Optimize dask array equality checks. (pydata#3453)
* upstream/master: format indexing.rst code with black (pydata#3511) add missing pint integration tests (pydata#3508) DOC: update bottleneck repo url (pydata#3507) add drop_sel, drop_vars, map to api.rst (pydata#3506) remove syntax warning (pydata#3505) Dataset.map, GroupBy.map, Resample.map (pydata#3459) tests for datasets with units (pydata#3447) fix pandas-dev tests (pydata#3491) unpin pseudonetcdf (pydata#3496) whatsnew corrections (pydata#3494) drop_vars; deprecate drop for variables (pydata#3475) uamiv test using only raw uamiv variables (pydata#3485) Optimize dask array equality checks. (pydata#3453) Propagate indexes in DataArray binary operations. (pydata#3481) python 3.8 tests (pydata#3477)
commit d430ae0 Author: dcherian <deepak@cherian.net> Date: Wed Nov 13 08:27:04 2019 -0700 proper fix. commit 7fd69be Author: dcherian <deepak@cherian.net> Date: Wed Nov 13 08:03:26 2019 -0700 fix whats-new merge. commit 4489394 Merge: 279ff1d b74f80c Author: dcherian <deepak@cherian.net> Date: Wed Nov 13 08:03:06 2019 -0700 Merge remote-tracking branch 'upstream/master' into fix/plot-broadcast * upstream/master: format indexing.rst code with black (pydata#3511) add missing pint integration tests (pydata#3508) DOC: update bottleneck repo url (pydata#3507) add drop_sel, drop_vars, map to api.rst (pydata#3506) remove syntax warning (pydata#3505) Dataset.map, GroupBy.map, Resample.map (pydata#3459) tests for datasets with units (pydata#3447) fix pandas-dev tests (pydata#3491) unpin pseudonetcdf (pydata#3496) whatsnew corrections (pydata#3494) drop_vars; deprecate drop for variables (pydata#3475) uamiv test using only raw uamiv variables (pydata#3485) Optimize dask array equality checks. (pydata#3453) Propagate indexes in DataArray binary operations. (pydata#3481) python 3.8 tests (pydata#3477) commit 279ff1d Author: dcherian <deepak@cherian.net> Date: Wed Nov 13 08:02:44 2019 -0700 Undo the transpose change and add test to make sure transposition is right. commit c9cc698 Author: dcherian <deepak@cherian.net> Date: Wed Nov 13 08:01:39 2019 -0700 Test to make sure transpose is right commit 9b35ecf Author: dcherian <deepak@cherian.net> Date: Sat Nov 2 15:49:08 2019 -0600 Additional test. commit 7aed950 Author: dcherian <deepak@cherian.net> Date: Sat Nov 2 15:20:07 2019 -0600 make plotting work with transposed nondim coords.
Introduces
drop_vars, and deprecates usingdropfor variables.dropis widely used for the deprecated case, so this is a fairly wide blast radius.It's more churn than is ideal, but I do think it's a much better API.
This is ready for review, though I'm sure I'm missed references in the docs etc (took my peak regex skills to find/replace only the deprecated usages!)
Originally discussed here
black . && mypy . && flake8whats-new.rstfor all changes andapi.rstfor new API