Skip to content

Test suite: raw np.zeros_like on backend-aware arrays in test_ccdproc_logging.py and test_rebin.py #970

Description

@mwcraig

Running the array-api-strict backend surfaces a test-suite defect: raw np.zeros_like called on backend-aware fixture arrays.

CCDPROC_ARRAY_LIBRARY=array-api-strict pytest \
    ccdproc/tests/test_ccdproc_logging.py ccdproc/tests/test_image_collection.py -q
# 1 failed, 85 passed

ccdproc/tests/test_ccdproc_logging.py:75:
    bias = CCDData(np.zeros_like(ccd_data.data), unit="adu")
RuntimeError: Can't convert array on the 'array_api_strict.Device('device1')'
device to a NumPy array.

Root cause: test_implicit_logging builds its CCDData via the shared ccd_data_func() fixture (ccdproc/tests/pytest_fixtures.py:66), which already constructs data through the configured backend (xp.asarray(..., device=xp_device)). The test then calls plain np.zeros_like(ccd_data.data) instead of the backend-aware xp.zeros_like pattern used consistently elsewhere (e.g. test_combiner.py:678, test_ccdproc.py:378). A second, identical instance exists at ccdproc/tests/test_rebin.py:70.

This is test-only, and narrower than the #941 table row. That row ("test_image_collection.py, test_ccdproc_logging.py:75, misc singletons", ~4 failures, "an ImageFileCollection gap") was verified at branch tip d329ac5: only the test_ccdproc_logging.py:75 failure reproduces. test_image_collection.py passes 77/77 under array-api-strict — ImageFileCollection defaults to numpy and only converts via xp.asarray when a caller explicitly passes array_package, so no library-side gap was found. The ImageFileCollection claim was either fixed since the 94ca9ec run or a false positive; no library issue is warranted.

Suggested fix: swap np.zeros_like for xp.zeros_like (using the per-test xp fixture as other test modules do) at ccdproc/tests/test_ccdproc_logging.py:75 and ccdproc/tests/test_rebin.py:70.

Part of the array-API triage in #941; found with the array-api-strict tooling from #937/#939.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions