From 3c2cfe7359b8577170b057a8a0d8634473539bbd Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Wed, 16 Oct 2024 11:15:02 -0400 Subject: [PATCH] Add Background2D regression tests --- .../background/tests/test_background_2d.py | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/photutils/background/tests/test_background_2d.py b/photutils/background/tests/test_background_2d.py index cd187e870..2d0dca010 100644 --- a/photutils/background/tests/test_background_2d.py +++ b/photutils/background/tests/test_background_2d.py @@ -12,7 +12,7 @@ from numpy.testing import assert_allclose, assert_equal from photutils.background.background_2d import Background2D -from photutils.background.core import MeanBackground +from photutils.background.core import MeanBackground, SExtractorBackground from photutils.background.interpolators import (BkgIDWInterpolator, BkgZoomInterpolator) from photutils.utils._optional_deps import HAS_MATPLOTLIB @@ -476,3 +476,23 @@ def test_masks(self): assert_equal(arr2, arr3) assert_equal(bkgimg1, bkgimg2) + + @pytest.mark.parametrize('bkg_est', [MeanBackground(), + SExtractorBackground()]) + def test_large_boxsize(self, bkg_est): + """ + Regression test to ensure that when boxsize is the same as the + image size that the input data left unchanged. + """ + shape = (103, 107) + data = np.ones(shape) + data[50:55, 50:55] = 1000.0 + data[20:25, 20:25] = 1000.0 + box_size = data.shape + filter_size = (3, 3) + data_orig = data.copy() + bkg = Background2D(data, box_size, filter_size=filter_size, + bkg_estimator=bkg_est) + bkgim = bkg.background + assert bkgim.shape == shape + assert_equal(data, data_orig)