-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Preserve all attrs with GroupBy by default. #7022
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
Conversation
Closes pydata#7012 When `use_flox=False`, we pass `keep_attrs=None` to `Data*.reduce`. This ends up delete Dataset and DataArray level attrs but preserves coordinate variable attrs. We now set the default to True always to match the default behaviour of `apply_ufunc` used by `flox.xarray.xarray_reduce`.
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.
LGTM.
@@ -65,6 +65,9 @@ Bug fixes | |||
By `András Gunyhó <https://github.com/mgunyho>`_. | |||
- Avoid use of random numbers in `test_weighted.test_weighted_operations_nonequal_coords` (:issue:`6504`, :pull:`6961`). | |||
By `Luke Conibear <https://github.com/lukeconibear>`_. | |||
- Use ``keep_attrs=True`` in grouping and resampling operations by default (:issue:`7012`). |
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 think they were kept without flox - do you want to mention this?
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.
Dataset level attrs were lost earlier:
Line 5603 in b018442
attrs = self.attrs if keep_attrs else None |
Now its always preserved whether you use flox or not. Should I clarify the second line here more.
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.
Should I clarify the second line here more.
Thanks for the clarification - fine to leave as is for me.
@@ -30,7 +30,7 @@ def dataset(): | |||
"foo": (("x", "y", "z"), np.random.randn(3, 4, 2)), | |||
"baz": ("x", ["e", "f", "g"]), | |||
}, | |||
{"x": ["a", "b", "c"], "y": [1, 2, 3, 4], "z": [1, 2]}, | |||
{"x": ("x", ["a", "b", "c"], {"name": "x"}), "y": [1, 2, 3, 4], "z": [1, 2]}, |
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 assume there is a assert_identical
somewhere below?
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.
Yes some existing tests failed when I added this.
@@ -65,6 +65,9 @@ Bug fixes | |||
By `András Gunyhó <https://github.com/mgunyho>`_. | |||
- Avoid use of random numbers in `test_weighted.test_weighted_operations_nonequal_coords` (:issue:`6504`, :pull:`6961`). | |||
By `Luke Conibear <https://github.com/lukeconibear>`_. | |||
- Use ``keep_attrs=True`` in grouping and resampling operations by default (:issue:`7012`). |
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.
Should I clarify the second line here more.
Thanks for the clarification - fine to leave as is for me.
Closes #7012
When
use_flox=False
, we passkeep_attrs=None
toData*.reduce
. This ends up delete Dataset and DataArray level attrs but preserves coordinate variable attrs. We now set the default to True always to match the default behaviour ofapply_ufunc
used byflox.xarray.xarray_reduce
.whats-new.rst