Problem
In the array branch of cosmicray_median, the masked-input handling is dead code — data = ccd.data is immediately overwritten by the unconditional data = xp.asarray(ccd) on the next statement:
|
# Only look at the data array, guessing that if there is a .mask then |
|
# there is also a .data. |
|
if hasattr(ccd, "mask"): |
|
data = ccd.data |
|
|
|
data = xp.asarray(ccd) |
|
|
|
if error_image is None: |
|
error_image = xp.std(data) |
|
elif not isinstance(error_image, float): |
|
if not _is_array(error_image): |
|
raise TypeError("error_image is not a float or ndarray.") |
|
|
|
# create the median image |
|
marr = ndimage.median_filter(data, size=(mbox, mbox)) |
|
|
So a masked array passed in is not handled the way the comment describes, and what xp.asarray does with an np.ma.MaskedArray (silently dropping the mask) is backend-dependent.
Notes
Found during a review of the array API implementation from #885; follow-up to #909 / #912.
Problem
In the array branch of
cosmicray_median, the masked-input handling is dead code —data = ccd.datais immediately overwritten by the unconditionaldata = xp.asarray(ccd)on the next statement:ccdproc/ccdproc/core.py
Lines 2030 to 2045 in 9d25eee
So a masked array passed in is not handled the way the comment describes, and what
xp.asarraydoes with annp.ma.MaskedArray(silently dropping the mask) is backend-dependent.Notes
scipy.ndimage.median_filteron the (possibly non-numpy) data a few lines later, which is covered by the CPU-only-operations policy issue Array API: decide a policy for inherently CPU-only operations #935.Found during a review of the array API implementation from #885; follow-up to #909 / #912.