From a35ac434fa53d9732e5c474224afc71f3822b7ec Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Fri, 7 Feb 2025 09:56:50 -0600 Subject: [PATCH 1/2] Remove plain numpy array as argument option --- CHANGES.rst | 3 +++ ccdproc/core.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 28bd4548..577dc6d1 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 eea5c03c..c5266c37 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 From b7a32bb2fc5889a664fca300e35cf1d7c842c7f8 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Fri, 7 Feb 2025 09:51:58 -0600 Subject: [PATCH 2/2] Add test for #866 --- ccdproc/tests/test_ccdproc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ccdproc/tests/test_ccdproc.py b/ccdproc/tests/test_ccdproc.py index b79883af..b2bc0ad6 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():