old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  
  import numpy as np
  from numpy.testing import assert_allclose
  import pytest
  from astropy.convolution import Gaussian2DKernel
  from astropy.tests.helper import catch_warnings
  from astropy.utils.exceptions import AstropyUserWarning
  
  from ..convolution import filter_data
  from ...datasets import make_100gaussians_image
  
  try:
      import scipy  # noqa
      HAS_SCIPY = True
  except ImportError:
      HAS_SCIPY = False
  
  
  @pytest.mark.skipif('not HAS_SCIPY')
  class TestFilterData:
      def setup_class(self):
          self.data = make_100gaussians_image()
          self.kernel = Gaussian2DKernel(3., x_size=3, y_size=3)
  
      def test_filter_data(self):
          fdata1 = filter_data(self.data, self.kernel)
          fdata2 = filter_data(self.data, self.kernel.array)
          assert_allclose(fdata1, fdata2)
  
      def test_filter_data_types(self):
          """
          Test to ensure output is a float array for integer input data.
          """
  
          fdata = filter_data(self.data.astype(int),
                              self.kernel.array.astype(int))
          assert fdata.dtype == np.float64
  
          fdata = filter_data(self.data.astype(int),
                              self.kernel.array.astype(float))
          assert fdata.dtype == np.float64
  
          fdata = filter_data(self.data.astype(float),
                              self.kernel.array.astype(int))
          assert fdata.dtype == np.float64
  
          fdata = filter_data(self.data.astype(float),
                              self.kernel.array.astype(float))
          assert fdata.dtype == np.float64
  
      def test_filter_data_kernel_none(self):
          """
          Test for kernel=None.
          """
  
          kernel = None
          fdata = filter_data(self.data, kernel)
          assert_allclose(fdata, self.data)
  
      def test_filter_data_check_normalization(self):
          """
          Test kernel normalization check.
          """
  
          with catch_warnings(AstropyUserWarning) as w:
              filter_data(self.data, self.kernel, check_normalization=True)
              assert len(w) == 1
  
new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  
  import numpy as np
  from numpy.testing import assert_allclose
  import pytest
  from astropy.convolution import Gaussian2DKernel
  from astropy.tests.helper import catch_warnings
  import astropy.units as u
  from astropy.utils.exceptions import AstropyUserWarning
  
  from ..convolution import filter_data
  from ...datasets import make_100gaussians_image
  
  try:
      import scipy  # noqa
      HAS_SCIPY = True
  except ImportError:
      HAS_SCIPY = False
  
  
  @pytest.mark.skipif('not HAS_SCIPY')
  class TestFilterData:
      def setup_class(self):
          self.data = make_100gaussians_image()
          self.kernel = Gaussian2DKernel(3., x_size=3, y_size=3)
  
      def test_filter_data(self):
          filt_data1 = filter_data(self.data, self.kernel)
          filt_data2 = filter_data(self.data, self.kernel.array)
          assert_allclose(filt_data1, filt_data2)
  
      def test_filter_data_units(self):
          unit = u.electron
          filt_data = filter_data(self.data * unit, self.kernel)
          assert isinstance(filt_data, u.Quantity)
          assert filt_data.unit == unit
  
      def test_filter_data_types(self):
          """
          Test to ensure output is a float array for integer input data.
          """
  
          filt_data = filter_data(self.data.astype(int),
                                  self.kernel.array.astype(int))
          assert filt_data.dtype == np.float64
  
          filt_data = filter_data(self.data.astype(int),
                                  self.kernel.array.astype(float))
          assert filt_data.dtype == np.float64
  
          filt_data = filter_data(self.data.astype(float),
                                  self.kernel.array.astype(int))
          assert filt_data.dtype == np.float64
  
          filt_data = filter_data(self.data.astype(float),
                                  self.kernel.array.astype(float))
          assert filt_data.dtype == np.float64
  
      def test_filter_data_kernel_none(self):
          """
          Test for kernel=None.
          """
  
          kernel = None
          filt_data = filter_data(self.data, kernel)
          assert_allclose(filt_data, self.data)
  
      def test_filter_data_check_normalization(self):
          """
          Test kernel normalization check.
          """
  
          with catch_warnings(AstropyUserWarning) as w:
              filter_data(self.data, self.kernel, check_normalization=True)
              assert len(w) == 1
  
subject: Add filter_data test for units