Keep Variance/InverseVariance uncertainty propagation in the array namespace - #975
Open
mwcraig wants to merge 2 commits into
Open
Keep Variance/InverseVariance uncertainty propagation in the array namespace#975mwcraig wants to merge 2 commits into
mwcraig wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #975 +/- ##
==========================================
+ Coverage 96.13% 96.65% +0.51%
==========================================
Files 8 8
Lines 1655 1672 +17
==========================================
+ Hits 1591 1616 +25
+ Misses 64 56 -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:
|
mwcraig
marked this pull request as ready for review
August 22, 2026 18:24
…mespace _VarianceUncertaintyWrapper and _InverseVarianceWrapper were bare subclasses, so their propagation went through astropy's default to_variance/from_variance hooks and the result escaped to NumPy on JAX and other non-NumPy backends. Factor the four _propagate_* overrides from _StdDevUncertaintyWrapper into a shared _ArrayAPIPropagationMixin whose subclasses supply the namespace-aware hooks, and use it for all three wrapper classes. Remove the two jax backend_xfail markers in test_cosmicray.py that covered this; they now pass outright. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA
mwcraig
force-pushed
the
fix-962-variance-wrappers
branch
from
August 23, 2026 14:35
088dc12 to
9549a1a
Compare
…pace Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RQMJZUaaxfqGDk41GLSaFK
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.
_VarianceUncertaintyWrapperand_InverseVarianceWrapperinccdproc/_ccddata_wrapper_for_array_api.pywere bare subclasses, so arithmetic on aCCDDatacarrying aVarianceUncertainty/InverseVariancewent through astropy's defaultto_variance/from_variancehooks and the propagated uncertainty escaped to NumPy on JAX (and other non-NumPy backends).This PR factors the four
_propagate_add/subtract/multiply/divideoverrides that_StdDevUncertaintyWrapperalready had into a small_ArrayAPIPropagationMixin; each wrapper supplies namespace-aware hooks via_variance_hooks(xp):xp.square/xp.sqrt(unchanged behaviour)xp.asarray1/x/1/xp.asarray(x)The two jax
backend_xfailparams ontest_cosmicray_gain_correct(VarianceUncertainty and InverseVariance withgain_apply=True) are removed; under jax they go XPASS -> PASS.Note: intermediates may still round-trip through NumPy inside astropy's
_VariancePropagationMixinitself (it callsnp.sqrt/np.absand checksisinstance(correlation, np.ndarray)); that is upstream and tracked in #940. This PR only fixes the ccdproc-side wrapper so the result stays in the data's namespace.Test matrix
pytest ccdprocJAX_ENABLE_X64=True)CCDPROC_ENFORCE_ESCAPE_BASELINE=1ccdproc/tests/test_cosmicray.pyunder array-api-strict: 1 failed, 7 passed, 33 xfailed both before and after (pre-existing failure, unrelated).Fixes #962
🤖 Generated with Claude Code
https://claude.ai/code/session_01DTN9DnPnLKK2u7knnMJ2gA