-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation on accessors? #2788
Comments
You don't really need to implement anything, you're effectively just adding new methods and properties to the class, you don't need to reimplement anything which is already there. @xarray.register_dataset_accessor('example')
class ExampleDataArrayAccessor():
def __init__(self, da):
pass
def hello_world(self):
print("hello world!")
ds = xr.Dataset({'longitude': np.linspace(0, 10), 'latitude': np.linspace(0, 20)})
ds.example.hello_world()
You've linked to the only example current in the official documentation. (I think there should be more examples.) However I found reading the discussion and examples in this issue thread pretty helpful. Also I have a very simple example of creating a dataset accessor here. |
@achapkowski We would appreciate it if you could suggest changes that would make the documentation less confusing. |
@dcherian A non-trivial example would help for both types of accessor patterns would help a lot and the best practice defined by the dev team on how to extend the API when needed. |
http://xarray.pydata.org/en/stable/internals.html#extending-xarray What about that example isn't clear enough? Would it help if the example in @TomNicholas's comment above was added to the documentation? |
I would like to extend the XArray library, but before I start, I am looking for more information. With Panda's Accessor pattern and DataArray, there was a defined pattern to extend the API.
What methods and properties must be implemented in DataArray to assure it works properly? Is there a full template/example of doing this?
http://xarray.pydata.org/en/stable/internals.html#extending-xarray
documentation seems to say you can create a DataSet, but doesn't show what is required for a dataset. Is there a module I can look at in the repository to show how this is done?The text was updated successfully, but these errors were encountered: