-
Notifications
You must be signed in to change notification settings - Fork 303
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
Make combine_arrays understand non-numpy arrays #1216
Make combine_arrays understand non-numpy arrays #1216
Conversation
Added a regression test triggering the ValueError raised when trying to read a FCI composite (see pytroll#1215).
In combine metadata, replace an ndarray instance check by a check for the array interface (attribute __array__).
Added another regression test to combine_metadata, that better simulates the situation with the FCI reader. The ancillary_variables attribute is actually List[xarray.DataArray], so this needs to be handled as well.
In combine_metadata, cover lists of arrays such as happen when trying to read an FCI composite.
The list of arrays was catching too much, such as [()]. Only catch lists of arrays when they are non-empty.
Codecov Report
@@ Coverage Diff @@
## master #1216 +/- ##
=========================================
Coverage ? 89.77%
=========================================
Files ? 202
Lines ? 30031
Branches ? 0
=========================================
Hits ? 26961
Misses ? 3070
Partials ? 0
Continue to review full report at Codecov.
|
From the
(I'd like to resolve these questions before I do more stylistic work, such as solving the issues codebeat is complaining about) |
One option would be that for arrays, instead of comparing the values, it compares object identity or perhaps uses |
I think this was supposed to mean "if the values of any keys are not equal". Regardless, would it just be safer/smarter to special case |
I don't know what we want, because I don't have a good idea of the intention of this function, how it is used in practice, or what might break in case of a false positive or false negative equals matching. I'm fine with any solution that doesn't involve computing the arrays at this stage. |
I think the original use case were things that are now included as ancillary_variables or as coordinates on a DataArray. For example, VIIRS has a moon illumination fraction that could be provided as a per-scan array. I think this is now requested/loaded as a separate dataset by the few composites that use it. Another example is pressure levels for the NUCAPS reader. I think these are still added to Off the top of my head, I think |
I would use 'is' as a comparator for datarrays |
In combine_metadata, compare arrays with object identity rather than by value, avoiding expensive computation. Refactor the combine_metadata function with three small helpers to reduce code complexity. Expand unit tests for combine_metadata.
PEP 8 fixes, forgot to remove #breakpoint() from test code.
The test failures appear unrelated to this PR. |
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 was hoping this new functionality would only apply to DataArrays and not numpy or dask arrays, but this is probably better overall.
Thanks!
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
Make
combine_arrays
understand non-numpy arrays in attributes. I believe this should fix #1215.flake8 satpy