home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 428179704

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/issues/2473#issuecomment-428179704 https://api.github.com/repos/pydata/xarray/issues/2473 428179704 MDEyOklzc3VlQ29tbWVudDQyODE3OTcwNA== 35968931 2018-10-09T12:52:30Z 2018-10-09T14:53:30Z MEMBER

Sorry for the triple comment, but I could also do this:

If I do this: ```python @xr.register_dataset_accessor('bout') class BoutAccessor(object): def init(self, ds_object): self._data = ds_object

def set_options(self, options):
    self.options = options

@register_dataset_accessor('storm') class StormAccessor(BoutAccessor): def init(self, ds_object): super().init(ds_object)

def special_storm_plot()
    special_storm_plot(self._data, self.options)

``` then I can have BOUT-specific attributes and methods stored via the bout accessor, all of which are inherited by the more-specific storm accessor

```python ds = collect_data(path) options_obj = get_options(path)

ds.storm.set_options(options_obj) # access inherited methods from the bout accessor to store arbitrary extra data

ds.storm.special_storm_plot() # use data from the bout accessor when calling more-specific methods form the storm accessor

```

However then my attached objects don't survive the calling of xarray methods: python ds.storm.extra_info = 'options' new_ds = ds.isel(t=-1) print(new_ds.storm.extra_info) # AttributeError: 'StormAccessor' object has no attribute 'extra_info'

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  367763373
Powered by Datasette · Queries took 0.694ms · About: xarray-datasette