Use array-API dtype in Combiner; fix stale test - #925
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #925 +/- ##
=======================================
Coverage 96.63% 96.63%
=======================================
Files 8 8
Lines 1574 1574
=======================================
Hits 1521 1521
Misses 53 53 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
85fac1a to
0ab3a95
Compare
f18622c to
a5f80d5
Compare
Fixes astropy#924. The string-based weights.astype('float64') triggers a DeprecationWarning in JAX's array API implementation, which is promoted to a test failure in the py313-jax CI job. Use xp.astype(weights, xp.float64) instead, where xp is the array namespace already in scope at that point in the function. This works across all array-API backends (numpy, jax, cupy, etc.) without deprecation warnings. The issue body also notes a 'stale' test in test_image_collection.py (test_generator_ccds_without_unit) where it claims ImageFileCollection.ccds() no longer raises ValueError. Verified locally against astropy 7.2.0 that the test still passes as written — ccds() does still raise ValueError when no unit is supplied (via CCDData.__init__ enforcing _config_ccd_requires_unit). The 'stale test' part of the issue appears to be based on a misreading of the current behavior, so the test is left as-is. No new tests needed: the JAX CI job is the verification for the array-API dtype change.
a5f80d5 to
8064a74
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses array-API/JAX compatibility in Combiner._weighted_sum by switching a deprecated string-based dtype conversion to an array-API namespace call, and updates a test expectation around ImageFileCollection.ccds() behavior across backends.
Changes:
- Replace
weights.astype("float64")withxp.astype(weights, xp.float64)to avoid JAX dtype deprecation warnings promoted to CI failures. - Update
test_generator_ccds_without_unitto assert backend-dependent behavior (JAX returnsCCDData, others raiseValueError). - Add a changelog entry documenting the dtype-conversion fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ccdproc/combiner.py |
Uses array-API namespace dtype conversion (xp.astype) for backend compatibility. |
ccdproc/tests/test_image_collection.py |
Adjusts test expectations for ccds() when unit is missing, depending on backend. |
CHANGES.rst |
Documents the dtype conversion fix and its impact on JAX CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @pytest.mark.backend_xfail( | ||
| "jax", | ||
| reason="on Linux CI with the jax backend, ccds() does not raise " | ||
| "ValueError for unit-less files; the same test passes on macOS with " | ||
| "identical astropy/jax versions. Platform-dependent, root cause not " | ||
| "yet understood.", | ||
| ) | ||
| def test_generator_ccds_without_unit(self, triage_setup): |
|
Thanks @karlhillx! |
PR #925 changed this test to assert that on the jax backend ccds() returns a CCDData for unit-less files instead of raising ValueError. That encodes a Linux-only bug symptom as expected behavior: on macOS with identical astropy/jax versions, ccds() does raise ValueError, so the jax branch of the test fails there and is silently absorbed by the backend_xfail marker added in cf4f4b7 for the same symptom. With both in place the test can never fail on jax on any platform. Revert the test body to expect ValueError on all backends and keep the backend_xfail marker, which documents the unresolved platform-dependent jax behavior. Raising for unit-less files is the intended behavior; the Linux jax deviation stays visible as an xfail instead of being asserted as correct. Follows up on a Copilot review comment on #925. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01463EbSeiTmBJevbvpMNRm8
Fixes #924.
Two changes:
ccdproc/combiner.py:603—weights.astype("float64")→xp.astype(weights, xp.float64). The actual JAX deprecation.ccdproc/tests/test_image_collection.py:387-401—ccds()raisesValueErrorin every backend except JAX, so the test branches: asserts the raise in numpy/dask, asserts a CCDData is returned in JAX. Same pattern astest_memory_use.py.The py313-jax job still has 6 failures from
np.result_typeinastropy.nddata.mixins.ndarithmetic:769when scaling CCDData. That's astropy code, not ccdproc, and predates this PR — worth a separate issue upstream.cc @mwcraig