Skip to content

Commit 85fac1a

Browse files
committed
Use array-API-compatible dtype conversion in Combiner._weighted_sum
Fixes #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.
1 parent 9d25eee commit 85fac1a

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2.5.2 (unreleased)
2+
------------------
3+
4+
Bug Fixes
5+
^^^^^^^^^
6+
7+
- Fix dtype conversion in ``Combiner._weighted_sum`` to use the array-API
8+
namespace form ``xp.astype(weights, xp.float64)`` instead of the deprecated
9+
string-based ``.astype("float64")``. This resolves the ``DeprecationWarning``
10+
that was being promoted to a test failure in the JAX CI job. [#924]
11+
112
2.5.1 (2025-07-05)
213
------------------
314

ccdproc/combiner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def _weighted_sum(self, data, sum_func, xp=None):
600600
# Turns out bn.nansum has an implementation that is not
601601
# precise enough for float32 sums. Doing this should
602602
# ensure the sums are carried out as float64
603-
weights = weights.astype("float64")
603+
weights = xp.astype(weights, xp.float64)
604604
weighted_sum = sum_func(data * weights, axis=0)
605605
return weighted_sum, weights
606606

0 commit comments

Comments
 (0)