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
transform.rescale no longer handles xarray object directly if preserve_range enabled #7124
Comments
Hi @yichechang, thank you for reporting and investigating the issue! I would say that native support for xr.DataArrays is something we may consider in the future, but not before they are widely supported by numpy and scipy (i.e. without issues similar to this one). We would also need to properly think through the assumptions we make about the users' xarrays (e.g., how we treat DataArray.coords and .dims), such that the library functions work in a consistent and expected way. That sounds like a big amount of work, and I would prefer to start it with specification (https://scientific-python.org/specs/). Regarding the regression you reported, I have opened a PR with the fix - #7159. Please, feel free to jump in and make a review. |
Hi @soupault, Thank you for your time and the PR! I'm currently traveling but plan to test it with my own data this weekend. I also want to say I agree with your thoughts on supporting xarray and the first step being coming up with a spec. I was pleasantly surprised when things worked in skimage after accidentally passing an |
I am of the same opinion. However, since the fix is trivial, it is fine to have it. |
Apologies for my delayed reply. I think the reasoning and implementation are correct, and based on some tests you posted in PR #7159 these look promising! Thank you again for fixing this, even if it doesn't get merged at the end, I still want to express my appreciation! (I attempted to test with my real data locally but there was some build issues that I didn't know how to resolve when trying to install this branch locally.) |
Description:
Starting in
0.21.0
, passing an xarray object (xarray.DataArray
) intotransform.rescale
no longer works ifpreserve_range
is set toTrue
. Like:Above would work in both
0.19.3
and0.20.0
.More detail can be found below, but before that, I just wanted to check if scikit-image would like to support passing say
xarray.DataArray
into most scikit-image functions? Because if that's not within the scope, it's perfectly fine that I can always pass in the underlying numpy array via DataArray's.data
attribute. (In that case, I'll simply close this issue...)Traceback
My understanding is that in
skimage/transform/_warp.py
, in function_clip_warp_output
(called byresize
/rescale
) there'sthat is now broken in
0.21.0
.(Specifically, I think this behavior might be introduced by PR #6852 while fixing other things?)
Way to reproduce:
Version information:
The text was updated successfully, but these errors were encountered: