Fix device bug in subtract_dark(scale=True) misreported as unit mismatch - #973
Merged
Merged
Conversation
…unit error The scale factor was created with a bare ``xp.asarray(scale_factor)``, which on a device-aware backend (array-api-strict on a non-default device, CuPy) lands on the default device and cannot be multiplied with the master dark. The resulting backend error was then caught by the ``ValueError`` clause of the surrounding ``except`` and re-raised as a spurious ``UnitsError`` about mismatched units. Create the scale factor on the master dark's device and drop ``ValueError`` from the caught exceptions; the real unit check raises ``UnitsError`` from the CCDData wrapper. Fixes astropy#966 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #973 +/- ##
=======================================
Coverage 95.83% 95.83%
=======================================
Files 8 8
Lines 1631 1631
=======================================
Hits 1563 1563
Misses 68 68 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pre-commit.ci has been failing on main since the black 26.5.1 bump in astropy#919 because black now requires a blank line after the module docstring in ccdproc/__init__.py. This is the only formatting change it wants. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
subtract_dark(scale=True)created the scale factor with a barexp.asarray(scale_factor), which on a device-aware backend (array-api-strict on a non-default device, CuPy) lands on the default device and cannot be multiplied with the master dark. The resulting backend error was caught by theValueErrorclause of the surroundingexceptand re-raised as a spuriousUnitsErrorabout mismatched units.This PR creates the scale factor on the master dark's device (same pattern as
gain_correct) and dropsValueErrorfrom the caught exceptions; the real unit check raisesUnitsErrorfrom the CCDData wrapper, andtest_subtract_dark_failsonly relies onTypeError/UnitsError.Test matrix (full
pytest ccdproc):CCDPROC_ENFORCE_ESCAPE_BASELINE=1ccdproc/tests/test_ccdproc.pyunder array-api-strict: before 32 failed / 31 passed / 10 xfailed; after 28 failed / 35 passed / 10 xfailed. The fourtest_subtract_dark[...scale=True]variants go from failing to passing; nobackend_xfailmarker was present on them.Fixes #966
🤖 Generated with Claude Code
https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA