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/issues/7220#issuecomment-1291969138,https://api.github.com/repos/pydata/xarray/issues/7220,1291969138,IC_kwDOAMm_X85NAeJy,14808389,2022-10-26T12:37:01Z,2022-10-26T19:42:42Z,MEMBER,see also the suggestions in https://github.com/pydata/xarray/pull/6461#discussion_r1004988864 and https://github.com/pydata/xarray/pull/6461#discussion_r1005023395,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423114234 https://github.com/pydata/xarray/issues/7220#issuecomment-1291957109,https://api.github.com/repos/pydata/xarray/issues/7220,1291957109,IC_kwDOAMm_X85NAbN1,39069044,2022-10-26T12:26:55Z,2022-10-26T12:26:55Z,CONTRIBUTOR,"Anything that uses `attrs[1]` and the `_get_all_of_type` helper is going to be hard to guarantee the behavior stated in the docstring, which is that we take the attrs of `x`. If `x` is a scalar, then `_get_all_of_type` returns a list of length 2 and `attrs[1]` ends up being the attrs of `y`. I think we may want to rework this, will try a few things later today.","{""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423114234 https://github.com/pydata/xarray/issues/7220#issuecomment-1291515219,https://api.github.com/repos/pydata/xarray/issues/7220,1291515219,IC_kwDOAMm_X85M-vVT,14371165,2022-10-26T05:18:52Z,2022-10-26T05:18:52Z,MEMBER,"Original looks like this: ```python # keep the attributes of x, the second parameter, by default to # be consistent with the `where` method of `DataArray` and `Dataset` keep_attrs = lambda attrs, context: attrs[1] ``` New one looks like this: ```python # keep the attributes of x, the second parameter, by default to # be consistent with the `where` method of `DataArray` and `Dataset` keep_attrs = lambda attrs, context: getattr(x, ""attrs"", {}) ``` I notice that the original return `attrs[1]` for some reason but the new doesn't. I haven't tried but try something like this: ```python def keep_attrs(attrs, context): attrs_ = getattrs(x, ""attrs"", {}) if attrs_: return attrs_[1] else: return attrs_ ``` I don't get where the x comes from though, seems scary to get something outside the function scope like this.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423114234