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/pull/806#issuecomment-218372473,https://api.github.com/repos/pydata/xarray/issues/806,218372473,MDEyOklzc3VlQ29tbWVudDIxODM3MjQ3Mw==,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}",,143877458
https://github.com/pydata/xarray/pull/806#issuecomment-202488506,https://api.github.com/repos/pydata/xarray/issues/806,202488506,MDEyOklzc3VlQ29tbWVudDIwMjQ4ODUwNg==,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}",,143877458
https://github.com/pydata/xarray/pull/806#issuecomment-202479266,https://api.github.com/repos/pydata/xarray/issues/806,202479266,MDEyOklzc3VlQ29tbWVudDIwMjQ3OTI2Ng==,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}",,143877458
https://github.com/pydata/xarray/pull/806#issuecomment-202476963,https://api.github.com/repos/pydata/xarray/issues/806,202476963,MDEyOklzc3VlQ29tbWVudDIwMjQ3Njk2Mw==,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}",,143877458