PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: astropy/ccdproc (python)

Issue:
`subtract_overscan` incorrectly allows a numpy array as input
See https://github.com/astropy/ccdproc/blob/main/ccdproc/core.py#L478

Both the docstring and code later in the function clearly assumes the thing passed in is a `CCDData` object.

Pull request:
Remove plain numpy array as argument option
Fixes #866 

Please have a look at the following list and replace the "[ ]" with a "[x]" if
the answer to this question is yes.

- [ ] For new contributors: Did you add yourself to the "Authors.rst" file?

For documentation changes:

- [ ] For documentation changes: Does your commit message include a "[skip ci]"?
      Note that it should not if you changed any examples!

For bugfixes:

- [x] Did you add an entry to the "Changes.rst" file?
- [ ] Did you add a regression test?
- [ ] Does the commit message include a "Fixes #issue_number" (replace "issue_number").
- [ ] Does this PR add, rename, move or remove any existing functions or parameters?

For new functionality:

- [ ] Did you add an entry to the "Changes.rst" file?
- [ ] Did you include a meaningful docstring with Parameters, Returns and Examples?
- [ ] Does the commit message include a "Fixes #issue_number" (replace "issue_number").
- [ ] Did you include tests for the new functionality?
- [ ] Does this PR add, rename, move or remove any existing functions or parameters?

Please note that the last point is not a requirement. It is meant as a check if
the pull request potentially breaks backwards-compatibility.

-----------------------------------------


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index 28bd454..577dc6d 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,6 +10,9 @@ Other Changes and Additions
 Bug Fixes
 ^^^^^^^^^
 
+- Do not allow the first argument of ``subtract_overscan`` to be a plain numpy
+  array. [#867]
+
 2.4.3 (2025-01-15)
 ------------------
 
diff --git a/ccdproc/core.py b/ccdproc/core.py
index eea5c03..c5266c3 100644
--- a/ccdproc/core.py
+++ b/ccdproc/core.py
@@ -475,8 +475,8 @@ def subtract_overscan(
     Spaces are stripped out of the ``fits_section`` string.
 
     """
-    if not (isinstance(ccd, CCDData) or isinstance(ccd, np.ndarray)):
-        raise TypeError("ccddata is not a CCDData or ndarray object.")
+    if not isinstance(ccd, CCDData):
+        raise TypeError("ccddata is not a CCDData object.")
 
     if (overscan is not None and fits_section is not None) or (
         overscan is None and fits_section is None


Test patch:
diff --git a/ccdproc/tests/test_ccdproc.py b/ccdproc/tests/test_ccdproc.py
index b79883a..b2bc0ad 100644
--- a/ccdproc/tests/test_ccdproc.py
+++ b/ccdproc/tests/test_ccdproc.py
@@ -305,6 +305,9 @@ def test_subtract_overscan_fails():
     # Does a fits_section which is not a string raise an error?
     with pytest.raises(TypeError):
         subtract_overscan(ccd_data, fits_section=5)
+    # Do we raise an error if the input is a plain array?
+    with pytest.raises(TypeError):
+        subtract_overscan(np.zeros((10, 10)), fits_section="[1:10]")
 
 
 def test_trim_image_fits_section_requires_string():