-
Notifications
You must be signed in to change notification settings - Fork 94
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
Fix gradient search for single band data #414
Conversation
Codecov Report
@@ Coverage Diff @@
## main #414 +/- ##
=======================================
Coverage 93.86% 93.87%
=======================================
Files 65 65
Lines 11125 11131 +6
=======================================
+ Hits 10443 10449 +6
Misses 682 682
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Does this error suggest that gradient search can't handle 3D+ inputs at all? |
I think it will handle N-D just fine, but in 2-D case with additioal |
Sorry I'm a little slow today. Doesn't this mean that the input data should have the |
That's an alternative, yes. But if the input has a shape |
I guess what I'm trying to say is why isn't the low level function getting a 2D array and then the higher level code is reconstructing a 3D array if needed? |
So first squeezing and then then re-expanding if necessary? Nope. This "squeeze if necessary" is a one step way for the same result. If the input data already have |
What I'm saying is if this resampling already handles multi-band images then how/why is your needed? If this method is only supposed to handle 2D arrays and the caller is supposed to handle the split/expand of a multi-band image (ex. RGB) then this change makes more sense but I'm still wondering why it is getting a 3D array as input if the caller is supposed to give it a 2D array. |
That's what the |
So what happens when you give an RGB to this resampler? |
It works exactly like it did before. |
I'm not suggesting your change breaks this. I'm suggesting that this fix isn't fixing the whole problem. If an RGB is given to this resampler, does it fail? If so, then the longer term fix (alternative to this current fix) would be to split the arrays, resample, and rejoin. If it doesn't fail, then there is something weird going on with dimensions here that whatever logic is supposed to be handling non-geo dimensions is not handling them correctly. |
No, RGB doesn't fail, as it has both |
Feel free to merge or wait for @mraspaud review. |
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.
LGTM, but it would be nice to know why :)
Xarray, correctly, doesn't add 3D coordinate/dimension labels to a 2D dataset. The input being originally a 3D representation of 2D data with dimensions |
Helping out a colleague, I noticed that gradient search resampler doesn't work if a single-channel dataset (shape
(1, y, x)
) are used.The error message was:
This PR fixes this by only applying
.squeeze()
in the case of result being of higher dimensionality than thedims
/coords
would indicate.git diff origin/main **/*py | flake8 --diff