Refactor _resampled_scene() and _reduce_data() methods of the Scene class - #3178
Refactor _resampled_scene() and _reduce_data() methods of the Scene class#3178pnuu wants to merge 9 commits into
_resampled_scene() and _reduce_data() methods of the Scene class#3178Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3178 +/- ##
==========================================
+ Coverage 96.32% 96.33% +0.01%
==========================================
Files 466 467 +1
Lines 59096 59143 +47
==========================================
+ Hits 56922 56977 +55
+ Misses 2174 2166 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I'll do some more refactoring to |
Pull Request Test Coverage Report for Build 16566762203Details
💛 - Coveralls |
_resampled_scene() and _reduce_data() methods of the Scene class
|
Thanks! I've merged this into #3168 but there is still an issue with missing test coverage. |
|
I made the Fine Choice(tm) of asking Copilot (Claude Sonnet 4.6) to refactor the method. After couple of iterations we ended up with this version that uses a data class to hold resampling context and a method that is called for each resampled dataset. |
|
Interesting...I've never personally used data classes beyond toy programs and watching programming videos. What it is doing here makes me wonder if this deserves a full blown helper class where instead of |
|
And sorry, I don't fully remember all the previous context for this PR and past thoughts I had about it. |
|
Unrelated test failure: I can't replicate this locally with package versions I have. |
|
Seems to be somehow related to pytest-dev/pytest#13974 that have several links from the few last days. |
|
Possible fix in #3415 |
|
Needs more test coverage? |
|
This PR increases the overhead/runtime of Satpy main: 8.2 seconds This PR: 44.0 seconds |
|
Profiling reveals:
Here both profiles: |
gerritholl
left a comment
There was a problem hiding this comment.
Serious performance regression in _reduce_data. The reductions dictionary appears no longer functional, leading to _reduce_data being called for every dataset. For my test script, that increases the time for calling resample from ca. 8 seconds to ca. 40 seconds. Without computing anything.
Fix a performance regression in _reduce_data, where the reductions dictionary was no longer used correctly, leading to reduce_data being called for every dataset instead of every source area.
This PR refactors
Scene._resampled_scene()that @gerritholl reported to be complicated in #3168 (comment) . As there was a change to_reduce_data(), I did some additional refactoring to it too.AUTHORS.mdif not there already