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/2970#issuecomment-605640846,https://api.github.com/repos/pydata/xarray/issues/2970,605640846,MDEyOklzc3VlQ29tbWVudDYwNTY0MDg0Ng==,14808389,2020-03-29T14:02:24Z,2020-03-29T14:02:24Z,MEMBER,"I think this is actually a python issue:
```python
def _make_cf(self):
self = xr.decode_cf(self)
```
since `self` is a variable name in python (by convention referring to the instance, but it is not treated different from other names), this
1. calculates `xr.decode_cf(self)` which returns a new dataset with decoded values
2. reassigns `self` to the result (so it does not refer to the class instance anymore)
So that while this was intended to be a inplace modification, it actually is the same as
```python
def _make_cf(self):
xr.decode_cf(self)
```
and does not do anything to the object.
In cases like this, use either aggregation or the `register_dataset_accessor`.
Here's how this looks with aggregation:
```python
class XResult:
def __init__(self, data=None, coords=None, attrs=None, **kwargs):
if isinstance(data, str):
kwargs = dict(READ_KWARGS, **kwargs)
with xr.open_dataset(data, **kwargs) as data:
attrs = data.attrs
self._data = xr.Dataset(data, coords, attrs)
self._make_cf(self._data)
def _make_cf(self):
self._data = xr.decode_cf(self._data)
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,445355249