-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
preserve chunked data when creating DataArray from DataArray #5984
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
preserve chunked data when creating DataArray from DataArray #5984
Conversation
…ata` test: add test for preserving chunks DataArray from DataArray creation
Co-authored-by: Illviljan <[email protected]>
…lf_described_chunked`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I can merge in a few days if there are no objections.
You could also add a short note to whats-new - probably under bug fixes.
edit: the test failure is unrelated.
How about we raise DeprecationWarning for now asking the user to pass in |
Makes sense - how about: msg = (
"Passing a `DataArray` object to the `DataArray` constructor is ambiguous.\n"
"Pass `da.data`, or use `da.copy(deep=True)`, or one of the `xarray.*_like` (e.g. "
"`xarray.zeros_like`) functions instead,\n"
"depending on your use case."
)
warnings.warn(msg, FutureWarning) |
Does this mean |
for reference, the situation we already deprecated and removed was passing In contrast to that, I think we can keep However, this might make the constructor a bit more difficult to understand so if we don't think that's worth the (minor) inconvenience: da if isinstance(da, xr.DataArray) else xr.DataArray(da) we can go ahead with the deprecation. |
Perfect, very much agree, thank you for the clear description @keewis ! |
Any objections to merging this as is? If we don't disallow However, xr.DataArray(da).data is da.data # True
xr.DataArray(da.data).data is da.data # True
# while
da.copy().data is da.data # False (deep=True is the default) might just be surprising in some situations. (Just for completeness - |
Sounds good to me then! |
Thank you, @FabianHofmann ! |
It was a pleasure! |
…0. 0.21.0 drops support for python 3.7. 0.20.2 has the bug. This commit tests if 0.20.1 does, too. issue: [preserve chunked data when creating DataArray from itself #5983](pydata/xarray#5983) corresponding pull request: [preserve chunked data when creating DataArray from DataArray #5984](pydata/xarray#5984) released in 0.21.0: [https://docs.xarray.dev/en/stable/whats-new.html#id81]
pre-commit run --all-files