issues: 479420466
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
479420466 | MDU6SXNzdWU0Nzk0MjA0NjY= | 3205 | Accessors are recreated on every access | 1828519 | closed | 0 | 3 | 2019-08-11T22:27:14Z | 2019-08-14T05:33:48Z | 2019-08-14T05:33:48Z | CONTRIBUTOR | MCVE Code Sample
```python import xarray as xr @xr.register_dataarray_accessor('test') class TestDataArrayAccessor(object): def init(self, obj): self._obj = obj print("DataArray accessor created") @xr.register_dataset_accessor('test') class TestDatasetAccessor(object): def init(self, obj): self._obj = obj print("Dataset accessor created") ```
```python import xarray as xr import numpy as np import test_accesor ds = xr.Dataset({'a': xr.DataArray(np.array([1, 2, 3])), 'b': xr.DataArray(np.array([4, 5, 6]))}) ds.test Dataset accessor created <accessor created on first access - expected>ds.test <no output - expected>ds['a'].test DataArray accessor created <accessor created on first access - expected>ds['a'].test DataArray accessor created <accessor created on second access - unexpected>var = ds['a'] var.test DataArray accessor created <accessor created on direct instance access - expected/unexpected>var.test <no output - expected>``` Expected OutputBased on the xarray accessor documentation I would have assumed that the accessor would stick around on the same DataArray object for the life of the data. My guess is that Problem DescriptionI'm currently working on an accessor for a new package called
Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/3205/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |