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
Refactor the combine_metadata function and allow numpy arrays to be combined #1309
Conversation
…ombined The `valid_range` array was not being combined properly because each dataarray had it's own copy of it. This refactor changes the behaviour of `combine_metadata` to just check the identities of lazy arrays, and use np.allclose otherwise.
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
==========================================
+ Coverage 90.01% 90.03% +0.01%
==========================================
Files 220 220
Lines 32254 32309 +55
==========================================
+ Hits 29035 29090 +55
Misses 3219 3219
Continue to review full report at Codecov.
|
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.
I think this looks good, but honestly it is hard to review with this new coding style. I know the code is overall more organized but I have to jump around between so many functions...this looks fine. I think originally Gerrit and I were trying to avoid every comparing numpy arrays. Not sure if that was how it was actually implemented before, but I'm fine with what you've done here.
I go from the assumption that heavy arrays will be lazy, so pure numpy arrays are OK to compare. As you can see in the tests, this was to compare eg valid_range 2-element arrays. Another solution would be to set a hardcoded limit on the length of arrays that we are OK with comparing. |
Might be a good idea in the future. I wish xarray would return valid_range as a tuple/list instead of an array. It will always be two elements. |
Regarding jumping between functions: I tried to always put a function's definition after it was used, so that we can go from high level to low level by reading from top to bottom. But yeah, reviewing isn't probably as linear anymore, but hopefully the intent and implementation of the functions is clearer now. |
The
valid_range
array was not being combined properly because each dataarray had it's own copy of it. This refactor changes the behaviour ofcombine_metadata
to just check the identities of lazy arrays, and use np.allclose otherwise.flake8 satpy