Array API: wcs_project mixes numpy output from reproject with xp operations
- Dominant language
- Python
- Stars
- 93
- Forks
- 92
- Avg merge
- 14h 44m
- Merged PRs (30d)
- 30
Description
### Problem
In `wcs_project`, `reproject_interp` returns numpy arrays regardless of the input library, but the subsequent mask handling uses the *input's* namespace:
https://github.com/astropy/ccdproc/blob/9d25eeefda8a38fc442c1a18e79ca2fa8ca40559/ccdproc/core.py#L1163-L1180
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.
Contributor guide
Research direction
Start in ccdproc/core.py at wcs_project and inspect how reproject_interp feeds the projected image and mask into the namespace operations. Read the CPU-only policy discussion in #935 and the related WCS issues #910 and #909 before choosing the supported behavior. Done means wcs_project has an explicit, documented namespace policy and no longer mixes incompatible array types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100