home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

12 rows where issue = 143877458 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 7

  • fmaussion 4
  • shoyer 2
  • khaeru 2
  • dopplershift 1
  • rabernat 1
  • jhamman 1
  • rafa-guedes 1

author_association 3

  • MEMBER 8
  • CONTRIBUTOR 2
  • NONE 2

issue 1

  • Decorators for registering custom accessors in xarray · 12 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
218372473 https://github.com/pydata/xarray/pull/806#issuecomment-218372473 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIxODM3MjQ3Mw== fmaussion 10050469 2016-05-11T06:23:27Z 2016-05-11T06:23:27Z MEMBER

Apart for the doc typo I mentioned, this looks very good, thanks!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
218341452 https://github.com/pydata/xarray/pull/806#issuecomment-218341452 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIxODM0MTQ1Mg== jhamman 2443309 2016-05-11T01:48:50Z 2016-05-11T01:48:50Z MEMBER

This looks good to me. Anyone else have any final comments?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
218301821 https://github.com/pydata/xarray/pull/806#issuecomment-218301821 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIxODMwMTgyMQ== shoyer 1217238 2016-05-10T21:46:37Z 2016-05-10T21:46:37Z MEMBER

Finally got around to updating this.

I added caching of these properties per @fmaussion's suggestion. Caching is a little error prone (I wrote a custom descriptor), but I think test cases should cover it pretty well.

{
    "total_count": 2,
    "+1": 2,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202631361 https://github.com/pydata/xarray/pull/806#issuecomment-202631361 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjYzMTM2MQ== rafa-guedes 7799184 2016-03-28T23:52:52Z 2016-03-28T23:52:52Z CONTRIBUTOR

:+1: nice one

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202527380 https://github.com/pydata/xarray/pull/806#issuecomment-202527380 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjUyNzM4MA== khaeru 1634164 2016-03-28T18:52:01Z 2016-03-28T18:53:35Z NONE

@fmaussion that's still helpful, thanks.

For cases where you want to do custom initialization, the suggestion (which I should add) is to simply write your own function to use in place of xarray.open_dataset.

Now that I think of it, it should also be possible to use some other in logic in __init__()—or even as a kludge store something like xarray_obj.attrs['_geoaccessor_state']—to determine whether the object is already, or needs to be, "initialized" (whatever that happens to mean for each accessor).

For instance, if the accessor creates and uses certain variables in a Dataset, it could check for their presence, and skip any initialization code if they already exist.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202488506 https://github.com/pydata/xarray/pull/806#issuecomment-202488506 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ4ODUwNg== fmaussion 10050469 2016-03-28T17:06:14Z 2016-03-28T17:06:14Z MEMBER

Thanks for the clarification. Would it make sense to make a @lazy_property out of it in oder to avoid multiple builds?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202486324 https://github.com/pydata/xarray/pull/806#issuecomment-202486324 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ4NjMyNA== shoyer 1217238 2016-03-28T17:03:13Z 2016-03-28T17:03:13Z MEMBER

Just to be clear—xarray_obj is passed to the init() method of an accessor. Will this happen before, or after Dataset.init()/DataArray.init() is invoked?

This will happen after Dataset.init/DataArray.init. For cases where you want to do custom initialization, the suggestion (which I should add) is to simply write your own function to use in place of xarray.open_dataset.

It's probably worth noting in the documentation that this is equivalent to just adding a property, e.g.,

python class Dataset: ... @property def geo(self) return GeoAccessor(self)

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202479266 https://github.com/pydata/xarray/pull/806#issuecomment-202479266 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ3OTI2Ng== fmaussion 10050469 2016-03-28T16:43:34Z 2016-03-28T16:43:34Z MEMBER

Oh, I realize that this doesn't answer your question though :flushed:

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202476963 https://github.com/pydata/xarray/pull/806#issuecomment-202476963 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ3Njk2Mw== fmaussion 10050469 2016-03-28T16:40:05Z 2016-03-28T16:40:05Z MEMBER

Yes, this looks very good, thanks!

@khaeru : I had the same question and just tested it:

``` python import xarray as xr import numpy as np

@xr.register_dataset_accessor('geo') class GeoAccessor(object): def init(self, xarray_obj): print('In constructor') self._obj = xarray_obj

@property
def center(self):
    # return the geographic center point of this dataset
    lon = self._obj.latitude
    lat = self._obj.longitude
    return (float(lon.mean()), float(lat.mean()))

def plot(self):
    print('plot data on a map')  # e.g., using Cartopy

Nothing is printed

ds = xr.Dataset({'longitude': np.linspace(0, 10), 'latitude': np.linspace(0, 20)})

out: In constructor

out = ds.geo.center

out: In constructor

plot data on a map

ds.geo.plot() ```

So the constructor is called only if the property is accessed, which is good. the drawback is that a new object is instantiated at each access.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202473784 https://github.com/pydata/xarray/pull/806#issuecomment-202473784 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ3Mzc4NA== khaeru 1634164 2016-03-28T16:31:59Z 2016-03-28T16:31:59Z NONE

Of the two different projects I'm working (sporadically) on that both subclass Dataset, it seems like one (pyGDX) should more properly be a backend, while the other could work as an accessor. This code looks good!

Just to be clear—xarray_obj is passed to the __init__() method of an accessor. Will this happen before, or after Dataset.__init__()/DataArray.__init__() is invoked?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202466876 https://github.com/pydata/xarray/pull/806#issuecomment-202466876 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ2Njg3Ng== dopplershift 221526 2016-03-28T16:16:06Z 2016-03-28T16:16:06Z CONTRIBUTOR

:+1: Very nice.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458
202450049 https://github.com/pydata/xarray/pull/806#issuecomment-202450049 https://api.github.com/repos/pydata/xarray/issues/806 MDEyOklzc3VlQ29tbWVudDIwMjQ1MDA0OQ== rabernat 1197350 2016-03-28T15:46:52Z 2016-03-28T15:46:52Z MEMBER

:+1: very cool

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  Decorators for registering custom accessors in xarray 143877458

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 1362.502ms · About: xarray-datasette