Skip to content
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

Add accessors #144

Merged
merged 6 commits into from Aug 23, 2022
Merged

Add accessors #144

merged 6 commits into from Aug 23, 2022

Conversation

TomNicholas
Copy link
Collaborator

@TomNicholas TomNicholas commented Aug 20, 2022

@TomNicholas TomNicholas added the enhancement New feature or request label Aug 20, 2022
@TomNicholas
Copy link
Collaborator Author

            @register_datatree_accessor("demo")
>           class Foo:
E           Failed: DID NOT WARN. No warnings of type (<class 'Warning'>,) were emitted. The list of emitted warnings is: [].

datatree/tests/test_extensions.py:39: Failed

This error occurs both locally and in CI, which is weird, because I just copied the code across from xarray.core.extensions and xarray.tests.test_extensions.py 😕

@keewis
Copy link
Contributor

keewis commented Aug 21, 2022

that's not weird, actually: the xarray test checks both Dataset and DataArray accessors at once, and thus it can delete the Dataset accessor and later check that redefining the DataArray accessor does correctly emit a warning (which DataTree can't, of course, because we're testing just a single class).

To fix this test, you can just move the del check below the warning check.

@TomNicholas
Copy link
Collaborator Author

that's not weird, actually

Good point, well made!

@TomNicholas TomNicholas merged commit f267f95 into xarray-contrib:main Aug 23, 2022
@TomNicholas TomNicholas deleted the accessor branch August 23, 2022 18:13
flamingbear pushed a commit to flamingbear/rewritten-datatree that referenced this pull request Jan 19, 2024
* test accessor

* implement accessor

* expose accessor

* whatsnew

* shut mypy up

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend datatree with custom accessors
2 participants