Problem
In wcs_project, reproject_interp returns numpy arrays regardless of the input library, but the subsequent mask handling uses the input's namespace:
|
projected_image_raw, _ = reproject_interp( |
|
(ccd.data, ccd.wcs), target_wcs, shape_out=target_shape, order=order |
|
) |
|
|
|
reprojected_mask = None |
|
if ccd.mask is not None: |
|
reprojected_mask, _ = reproject_interp( |
|
(ccd.mask, ccd.wcs), target_wcs, shape_out=target_shape, order=order |
|
) |
|
# Make the mask 1 if the reprojected mask pixel value is non-zero. |
|
# A small threshold is included to allow for some rounding in |
|
# reproject_interp. |
|
reprojected_mask = reprojected_mask > 1e-8 |
|
|
|
# The reprojection will contain nan for any pixels for which the source |
|
# was outside the original image. Those should be masked also. |
|
output_mask = xp.isnan(projected_image_raw) |
|
|
With xp = cupy, xp.isnan(projected_image_raw) receives a numpy array — CuPy functions reject numpy input (TypeError: 'a' must be a cupy.ndarray). Even where it happens to work, the returned CCDData holds numpy data while the caller supplied another library's array, silently switching namespaces mid-pipeline. Likely contributes to the WCS-related failures in #910.
Suggested direction
reproject is CPU-only, so this falls under the general policy decision for CPU-only operations (#935): either convert explicitly to host, reproject, and convert the result (data and mask) back to the input namespace — or document wcs_project as numpy-only and raise an informative error.
Found during a review of the array API implementation from #885; follow-up to #909 / #910.
Problem
In
wcs_project,reproject_interpreturns numpy arrays regardless of the input library, but the subsequent mask handling uses the input's namespace:ccdproc/ccdproc/core.py
Lines 1163 to 1180 in 9d25eee
With
xp = cupy,xp.isnan(projected_image_raw)receives a numpy array — CuPy functions reject numpy input (TypeError: 'a' must be a cupy.ndarray). Even where it happens to work, the returnedCCDDataholds numpy data while the caller supplied another library's array, silently switching namespaces mid-pipeline. Likely contributes to the WCS-related failures in #910.Suggested direction
reprojectis CPU-only, so this falls under the general policy decision for CPU-only operations (#935): either convert explicitly to host, reproject, and convert the result (data and mask) back to the input namespace — or documentwcs_projectas numpy-only and raise an informative error.Found during a review of the array API implementation from #885; follow-up to #909 / #910.