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

Update open_dataset backend to ensure compatibility with new explicit index model #7150

Merged
merged 9 commits into from
Oct 12, 2022
Merged

Update open_dataset backend to ensure compatibility with new explicit index model #7150

merged 9 commits into from
Oct 12, 2022

Conversation

lukasbindreiter
Copy link
Contributor

Based on feedback on this issue: #7139

Copy link
Member

@benbovy benbovy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lukasbindreiter for this PR!

I think it works in most cases but maybe not in all cases. CopyOnWriteArray is not useful for an (immutable) indexed coordinate variable, but wrapping variable data in a MemoryCachedArray might still be relevant for custom "lazy" indexes. Unfortunately, we don't have any example yet for the latter. Let's go ahead with your fix and address the general case later.

Would it be possible to add a test with a multi-index? Not sure how best to do that as I'm not familiar with this part of Xarray (backends) and how tests are written there.

xarray/backends/api.py Outdated Show resolved Hide resolved
@lukasbindreiter
Copy link
Contributor Author

Would it be possible to add a test with a multi-index?

I added such a test now (which fails with the old version of _protect_dataset_variables_inplace but runs through with the updated version of this PR)

Copy link
Member

@benbovy benbovy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small suggestion below.

Could you also update whats_new.rst with your contribution please?

xarray/tests/test_backends_api.py Outdated Show resolved Hide resolved
@lukasbindreiter
Copy link
Contributor Author

Could you also update whats_new.rst with your contribution please?

Done 👍

doc/whats-new.rst Outdated Show resolved Hide resolved
@benbovy
Copy link
Member

benbovy commented Oct 12, 2022

Thank you @lukasbindreiter! Merging.

I notice that this is your first contribution to Xarray, welcome!

@benbovy benbovy merged commit 3599f87 into pydata:main Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xarray.open_dataset has issues if the dataset returned by the backend contains a multiindex
3 participants