home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 592275751

This data as json

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-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
Powered by Datasette · Queries took 0.759ms · About: xarray-datasette