-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global option to always keep/discard attrs on operations #2482
Conversation
Hello @TomNicholas! Thanks for updating the PR.
Comment last updated on October 29, 2018 at 15:19 Hours UTC |
…es for reduce methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to look more carefully at the tests here....
Unit tests and docs look good. |
I wanted to clean up my commits using git rebase, but when I tried |
@TomNicholas I'm not sure, but don't worry about cleaning up git history with rebase. We squash all commits before merging anyways, and GitHub's review tools work a little better when you don't rebase. |
No idea why the CI test fails now - I literally changed one line, from |
@TomNicholas it looks like the merge conflict in |
@TomNicholas thanks, things look better now. Don't worry about the Appveyor failures; a new version of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @TomNicholas. There still seems to be a few redundant instances of the if
block.
…inted out by dcherian)
Thanks @TomNicholas ! |
* master: Global option to always keep/discard attrs on operations (pydata#2482) Remove tests where answers change in cftime 1.0.2.1 (pydata#2522) Finish deprecation cycle for DataArray.__contains__ checking array values (pydata#2520) Fix bug where OverflowError is not being raised (pydata#2519)
* upstream/master: (122 commits) add missing , and article in error message (pydata#2557) Add libnetcdf, libhdf5, pydap and cfgrib to xarray.show_versions() (pydata#2555) revert to dev version for 0.11.1 Release xarray v0.11 DOC: update whatsnew for xarray 0.11 release (pydata#2548) Drop the hack needed to use CachingFileManager as we don't use it anymore. (pydata#2544) add full test env for py37 ci env (pydata#2545) Remove old-style resample example in documentation (pydata#2543) Stop loading tutorial data by default (pydata#2538) Remove the old syntax for resample. (pydata#2541) Remove use of deprecated, unused keyword. (pydata#2540) Deprecate inplace (pydata#2524) Zarr chunking (GH2300) (pydata#2487) Include multidimensional stacking groupby in docs (pydata#2493) (pydata#2536) Switch enable_cftimeindex to True by default (pydata#2516) Raise more informative error when converting tuples to Variable. (pydata#2523) Global option to always keep/discard attrs on operations (pydata#2482) Remove tests where answers change in cftime 1.0.2.1 (pydata#2522) Finish deprecation cycle for DataArray.__contains__ checking array values (pydata#2520) Fix bug where OverflowError is not being raised (pydata#2519) ...
long_name
andunits
lost on.mean()
#442, Keep attrs & Add a 'keep_coords' argument to Dataset.apply #688, Attributes are currently kept when arrays are resampled, and not when datasets are resampled #828, Hooks for custom attribute handling in xarray operations #988, Shouldn't .where() pass the attributes of DataArrays and DataSets? #1009, Attrs are lost in mathematical computation #1271, Add CRS/projection information to xarray objects #2288, Recommended way to extend xarray Datasets using accessors? #2473Adds a global option to either always keep or always discard attrs in method and function calls.
The behaviour is backwards-compatible, as the logic is:
keep_attrs
supplied as keyword argument then use thatxarray.set_options(keep_attrs=True)
) is set then use thatkeep_attrs
argument for that particular function/method (kept the same as they were for backwards-compatibility).Main use cases include users who want to store the units of their data in the attrs, users who want to always keep information about the source or history of their data, and users who want to store objects in their attributes which are needed to supplement the xarray objects (e.g. an
xgcm.grid
). It should eventually be superceded by hooks for custom attribute handling (#988), but will be useful until then.I have left the top-level functions like
concat
andmerge
alone. Currently concat keeps the attributes of the first object passed to it, and merge returns a dataset with no attributes. It's not clear how this should be treated though, so I left it to users to extend those functions if they need to.