html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/pull/3801#issuecomment-593668722,https://api.github.com/repos/pydata/xarray/issues/3801,593668722,MDEyOklzc3VlQ29tbWVudDU5MzY2ODcyMg==,5635139,2020-03-02T23:03:19Z,2020-03-02T23:03:19Z,MEMBER,Thanks a lot @amcnicho ! Glad to have you as a contributor!,"{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-593486987,https://api.github.com/repos/pydata/xarray/issues/3801,593486987,MDEyOklzc3VlQ29tbWVudDU5MzQ4Njk4Nw==,5635139,2020-03-02T16:23:01Z,2020-03-02T16:23:01Z,MEMBER,"Looks great! Any feedback from others? Otherwise will merge later today Thanks @amcnicho !","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592279243,https://api.github.com/repos/pydata/xarray/issues/3801,592279243,MDEyOklzc3VlQ29tbWVudDU5MjI3OTI0Mw==,24736507,2020-02-28T02:25:35Z,2020-03-02T15:31:31Z,NONE,"Hello @amcnicho! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: ##### Comment last updated at 2020-03-02 15:31:30 UTC","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592986729,https://api.github.com/repos/pydata/xarray/issues/3801,592986729,MDEyOklzc3VlQ29tbWVudDU5Mjk4NjcyOQ==,5635139,2020-02-29T19:40:41Z,2020-02-29T19:40:41Z,MEMBER,"This looks excellent! Could we add the change to `whatsnew.rst`? Then I think we're ready to merge!","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592964963,https://api.github.com/repos/pydata/xarray/issues/3801,592964963,MDEyOklzc3VlQ29tbWVudDU5Mjk2NDk2Mw==,29958771,2020-02-29T16:49:25Z,2020-02-29T16:49:25Z,CONTRIBUTOR,"> Re the 2nd 'failure mode': IIUC the current tests should still pass, and that's a separate (and correct) case; is that right? That's right. The original test used test_reduce_keep_attrs as a template. Now, instead of defining one Variable object and passing it to both test conditions, a new Variable is defined and coarsened to check each setting of the global option. I will merge master in and add similar tests for `Rolling`.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592802437,https://api.github.com/repos/pydata/xarray/issues/3801,592802437,MDEyOklzc3VlQ29tbWVudDU5MjgwMjQzNw==,29958771,2020-02-29T01:21:25Z,2020-02-29T01:21:25Z,CONTRIBUTOR,"The recent changes I made to both the code and the tests result in a pass condition for both the dataset and variable version of test_coarsen_keep_attrs. I think adding the keep_attrs keyword argument to the `Variable.coarsen` method would be a breaking change, so I didn’t do that. Instead I added a check for the global setting inside the hidden method that reduces input Variable objects. Note that there are at least two failure modes remaining: - In the Dataset case, if the keep_attrs keyword is provided via the wrapper function (in this case `mean`) it results in the same `TypeError` as before because the converted functions don't expect the new keyword. I left the failing part of the test commented out because I'm not sure if this is supposed to be a supported usage mode. - In the Variable case, the default behavior of dropping the attributes is permanent, so the operation is non-commutative if coarsening the same Variable instance (even when creating new objects). This seemed acceptable behavior for manipulating primitives.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592763573,https://api.github.com/repos/pydata/xarray/issues/3801,592763573,MDEyOklzc3VlQ29tbWVudDU5Mjc2MzU3Mw==,29958771,2020-02-28T22:44:41Z,2020-02-28T22:44:41Z,CONTRIBUTOR,"Thank you for the review, I’ll incorporate those changes. No, the dataset test still raises `xarray/core/duck_array_ops.py:311: TypeError: nanmean() got an unexpected keyword argument 'keep_attrs'` and the variable test still fails due to assertion error. I think I understand why now though. Will test implementation and report. ","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592288706,https://api.github.com/repos/pydata/xarray/issues/3801,592288706,MDEyOklzc3VlQ29tbWVudDU5MjI4ODcwNg==,5635139,2020-02-28T03:06:42Z,2020-02-28T03:06:42Z,MEMBER,That's looking good re coarsen! Do tests pass?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592280108,https://api.github.com/repos/pydata/xarray/issues/3801,592280108,MDEyOklzc3VlQ29tbWVudDU5MjI4MDEwOA==,29958771,2020-02-28T02:29:03Z,2020-02-28T02:29:03Z,CONTRIBUTOR,"Sorry, I changed this from a draft to ready for review accidentally, and it doesn't look like there is a way to reverse that operation. The tests still fail after this latest change, but I think we are converging on a fix. The variable.coarsen method is applied to each of the arrays inside `wrapped_func`, so once that is fixed to recognize the global setting both tests should pass.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592275751,https://api.github.com/repos/pydata/xarray/issues/3801,592275751,MDEyOklzc3VlQ29tbWVudDU5MjI3NTc1MQ==,29958771,2020-02-28T02:11:30Z,2020-02-28T02:11:30Z,CONTRIBUTOR,"> Your current Rolling implementation looks good. Does that work? I couldn't find a test that checks attribute persistence across rolling window operations, but when I tested it interactively e.g. ``` dat = ds.rolling({'coord':1}, keep_attrs=True).mean() dat = ds.rolling({'coord':1}).mean(keep_attrs=True) assert dat.attrs == _attrs ``` it still doesn't seem to work. I agree that it is better to focus on `Coarsen` only for now. > For Coarsen, adding keep_attrs to the constructor is right, and then it needs to be assigned it to the object Yes, I seem not to have included the assignment, or it got lost along the way. I added it with a new commit. Thank you for noticing that. > Unlike the Rolling implementation, you can add the logic for keeping attrs within the wrapped_func by branching on the value of self.keep_attrs; self there is the Coarsen object. I think I see now. `DatasetCoarsen._reduce_method.wrapped_func()` accepts the DatasetCoarsen instance created by the `xr.Dataset.coarsen()` call. I will try to add a conditional inside that method's function to propagate the attributes along with the rest of the reduced object based on the value of the keep_attrs keyword.","{""total_count"": 1, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 1, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592219280,https://api.github.com/repos/pydata/xarray/issues/3801,592219280,MDEyOklzc3VlQ29tbWVudDU5MjIxOTI4MA==,5635139,2020-02-27T22:54:06Z,2020-02-27T22:54:06Z,MEMBER,"@amcnicho - Your current `Rolling` implementation looks good. Does that work? - For `Coarsen`, adding `keep_attrs` to the [constructor](https://github.com/pydata/xarray/pull/3801/files#diff-ed1ee8c19aef738886f1009d3008a4b1R537) is right, and then it needs to be assigned it to the object - Unlike the `Rolling` implementation, you can add the logic for keeping attrs _within_ the `wrapped_func` (i.e. [here](https://github.com/pydata/xarray/pull/3801/files#diff-ed1ee8c19aef738886f1009d3008a4b1R628) ), by branching on the value of `self.keep_attrs`; `self` there is the `Coarsen` object. Does that make sense?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592171368,https://api.github.com/repos/pydata/xarray/issues/3801,592171368,MDEyOklzc3VlQ29tbWVudDU5MjE3MTM2OA==,5635139,2020-02-27T20:53:06Z,2020-02-27T22:51:49Z,MEMBER,"Right, yes, this does get a bit nested... Appreciate you working through it. At first glance, `_reduce_method` works differently in `Rolling` & `Coarsen`. You can consider leaving `Rolling` and just focusing on `Coarsen`. ~I think you want to catch the kwarg [here](https://github.com/pydata/xarray/blob/master/xarray/core/rolling.py#L617)~ and use it to decide whether to include the attrs [here](https://github.com/pydata/xarray/blob/master/xarray/core/rolling.py#L647). It should _not_ be a kwarg into [`wrapped_func`](https://github.com/pydata/xarray/blob/master/xarray/core/rolling.py#L626). Does that make sense?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592172830,https://api.github.com/repos/pydata/xarray/issues/3801,592172830,MDEyOklzc3VlQ29tbWVudDU5MjE3MjgzMA==,5635139,2020-02-27T20:56:49Z,2020-02-27T20:56:49Z,MEMBER,"...but then potentially it does conflict with the existing use of `_reduce_method`. I can have more of a look tonight. CC @fujiisoup if you're more familiar with this code. And @dcherian has done some work on it.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592157343,https://api.github.com/repos/pydata/xarray/issues/3801,592157343,MDEyOklzc3VlQ29tbWVudDU5MjE1NzM0Mw==,29958771,2020-02-27T20:17:56Z,2020-02-27T20:17:56Z,CONTRIBUTOR,"It appears to be the mean function operating on the coarsen object [xarray/tests/test_dataset.py#l.5676](https://github.com/pydata/xarray/pull/3801/commits/af7bd10fa22d126b03639dff3c1e3ddd1a1ddef3#diff-f82411dbe6aa53e3b6a5d9c2b601094cR5676). The `Rolling` class uses `_reduce_method()` to check if the calling function is present in duck_array_ops, presumably to enable extensibility in line with NEP22. FWIW the dataset object returned by that call in the test looks like this: ``` values = array([[10. , 10.05050505, 10.1010101 , 10.15151515, 10.2020202 ], [10.25252525, 10.3030303 , 10.3535353...96 , 14.64646465, 14.6969697 , 14.74747475], [14.7979798 , 14.84848485, 14.8989899 , 14.94949495, 15. ]]) axis = (1,), skipna = None, kwargs = {'keep_attrs': True}, func = , nanname = 'nanmean' ``` ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592145566,https://api.github.com/repos/pydata/xarray/issues/3801,592145566,MDEyOklzc3VlQ29tbWVudDU5MjE0NTU2Ng==,5635139,2020-02-27T19:49:37Z,2020-02-27T19:49:37Z,MEMBER,"(sorry, I didn't see your message before my message prior) Do you know what's calling `nanmean` with `keep_attrs`? I think should be handling `keep_attrs` before we get to those numerical functions on variables.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592137938,https://api.github.com/repos/pydata/xarray/issues/3801,592137938,MDEyOklzc3VlQ29tbWVudDU5MjEzNzkzOA==,29958771,2020-02-27T19:32:54Z,2020-02-27T19:32:54Z,CONTRIBUTOR,`DatasetRolling.reduce` passes along **kwargs. `DatasetRolling.construct` does not. Maybe it needs to?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592136711,https://api.github.com/repos/pydata/xarray/issues/3801,592136711,MDEyOklzc3VlQ29tbWVudDU5MjEzNjcxMQ==,5635139,2020-02-27T19:30:18Z,2020-02-27T19:30:18Z,MEMBER,Recent commits look good @amcnicho !,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-592135306,https://api.github.com/repos/pydata/xarray/issues/3801,592135306,MDEyOklzc3VlQ29tbWVudDU5MjEzNTMwNg==,29958771,2020-02-27T19:27:05Z,2020-02-27T19:27:05Z,CONTRIBUTOR,"I added code to pass the keyword through and handle it in the constructor of the `Coarsen` classes, and also `Rolling` because that seemed to be necessary as well. Now the test_dataset version of test_coarsen_keep_attrs fails due to a TypeError in the function `nanmean()`. The test_variable version fails the same way as before. A run of the whole test_dataset suite shows all the rest are running as they are on master. This function `nanmean()` is a child of `duck_array_ops._create_nan_agg_method()` which seems like it should be happily passing along an arbitrary list of kwargs. The statement in the docstring > None of these functions should accept or return xarray objects. makes me suspicious that this keep_attrs keyword shouldn't be reaching this section of the code though. Any guidance would be appreciated.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567 https://github.com/pydata/xarray/pull/3801#issuecomment-591740060,https://api.github.com/repos/pydata/xarray/issues/3801,591740060,MDEyOklzc3VlQ29tbWVudDU5MTc0MDA2MA==,5635139,2020-02-27T02:05:37Z,2020-02-27T02:05:37Z,MEMBER,Thanks for the PR and tests @amcnicho . Are you up for adding the code to pass through `keep_attrs`?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,571743567