Exclude masked weights from average combinations - #952
Conversation
Signed-off-by: Simon Aguilera <saguilera1608@gmail.com>
Signed-off-by: Simon Aguilera <saguilera1608@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes weighted-average combination behavior so that masked/clipped/non-finite samples don’t incorrectly contribute their weights to the weighted-average denominator, aligning combine(..., method="average", weights=...) with expectations for masked/clipped data.
Changes:
- Adjust weighted-average computation to zero out weights corresponding to masked/clipped (NaN-substituted) samples before forming the denominator.
- Add regression tests covering frame weights, per-pixel weights, clipping, fully-masked output, custom callbacks, and weighted sums.
- Update release notes and contributor list.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ccdproc/combiner.py |
Excludes weights at NaN-substituted (masked/clipped) positions from the weighted-average denominator. |
ccdproc/tests/test_combiner.py |
Adds direct regression tests for weighted-average behavior with masking/clipping and related edge cases. |
CHANGES.rst |
Documents the bug fix in the unreleased changelog section. |
AUTHORS.rst |
Adds a new contributor entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #952 +/- ##
==========================================
+ Coverage 96.56% 96.63% +0.07%
==========================================
Files 8 8
Lines 1571 1574 +3
==========================================
+ Hits 1517 1521 +4
+ Misses 54 53 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Simon Aguilera <saguilera1608@gmail.com>
mwcraig
left a comment
There was a problem hiding this comment.
Thanks for the PR< and apologies for the delayed merge!
Summary
Fixes #893
Validation
python -m pytest ccdproc -q— 337 passed, 29 skippedpython -m pytest ccdproc/tests/test_combiner.py -q— 80 passedruff check ccdproc/combiner.py ccdproc/tests/test_combiner.pyblack --check ccdproc/combiner.py ccdproc/tests/test_combiner.pygit diff --checkThe array-api-strict backend was not counted as patch validation because current
mainfails earlier in existingCombinerconstruction and publiccombine()code. PR #925 changes an adjacent dtype-conversion line; this PR deliberately leaves that conversion untouched.AI assistance disclosure
I used OpenAI Codex to assist with repository inspection, test design, implementation, and review. I reviewed the resulting changes and take responsibility for their correctness and maintenance.
Checklist
AUTHORS.rstfile?[skip ci]? (Not applicable.)CHANGES.rstfile?Fixes #issue_number?