code: def test_sum_filter(self):
      i = numpy.array([[1, 2, 3], [3, 4, 5], [5, 6, 7]])
  
      # test reaction to size parameter
      r = sum_filter(i, size=1)
      numpy.testing.assert_allclose(r, i)
  
      e = numpy.array([[10, 14, 8], [18, 22, 12], [11, 13, 7]])
      r = sum_filter(i, size=2, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      e = numpy.array([[10, 18, 14], [21, 36, 27], [18, 30, 22]])
      r = sum_filter(i, size=3, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      e = numpy.array([[36, 36, 36], [36, 36, 36], [36, 36, 36]])
      r = sum_filter(i, size=5, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      r = sum_filter(i, size=10, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      # test reaction to footprint parameter
      fp = numpy.array([[1]])
      r = sum_filter(i, footprint=fp)
      numpy.testing.assert_allclose(r, i)
  
      fp = numpy.array([[1, 1], [1, 1]])
      e = numpy.array([[10, 14, 8], [18, 22, 12], [11, 13, 7]])
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      fp = numpy.array([[1, 1]])
      e = numpy.array([[3, 5, 3], [7, 9, 5], [11, 13, 7]])
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      fp = numpy.array([[1], [1]])
      e = numpy.array([[4, 6, 8], [8, 10, 12], [5, 6, 7]])
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      fp = numpy.array([[1, 0], [1, 0], [0, 1]])
      e = numpy.array([[5, 7, 3], [10, 13, 8], [8, 10, 12]])
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      fp = numpy.array([[1, 0], [0, 1], [0, 1]])
      e = numpy.array([[6, 8, 0], [11, 14, 3], [9, 11, 5]])
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      numpy.testing.assert_allclose(r, e)
  
      # test border treatment modes
      i = numpy.array([[1, 3, 4], [2, 2, 2]])
      fp = numpy.array([[1, 0, 1]])
  
      e = 6
      r = sum_filter(i, footprint=fp, mode="mirror")
      self.assertAlmostEqual(r[0, 0], e, msg="mirror mode failed")
  
      e = 4
      r = sum_filter(i, footprint=fp, mode="reflect")
      self.assertAlmostEqual(r[0, 0], e, msg="reflect mode failed")
  
      e = 7
      r = sum_filter(i, footprint=fp, mode="wrap")
      self.assertAlmostEqual(r[0, 0], e, msg="wrap mode failed")
  
      e = 4
      r = sum_filter(i, footprint=fp, mode="nearest")
      self.assertAlmostEqual(r[0, 0], e, msg="nearest mode failed")
  
      e = 3
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      self.assertAlmostEqual(r[0, 0], e, msg="constant mode failed")
  
      e = 12
      r = sum_filter(i, footprint=fp, mode="constant", cval=9)
      self.assertAlmostEqual(r[0, 0], e, msg="constant mode failed")
  
      fp = numpy.array([[1, 0, 0], [0, 0, 0]])
  
      e = 3
      r = sum_filter(i, footprint=fp, mode="mirror")
      self.assertAlmostEqual(r[0, 0], e, msg="mirror mode failed")
  
      e = 1
      r = sum_filter(i, footprint=fp, mode="reflect")
      self.assertAlmostEqual(r[0, 0], e, msg="reflect mode failed")
  
      e = 4
      r = sum_filter(i, footprint=fp, mode="wrap")
      self.assertAlmostEqual(r[0, 0], e, msg="wrap mode failed")
  
      e = 1
      r = sum_filter(i, footprint=fp, mode="nearest")
      self.assertAlmostEqual(r[0, 0], e, msg="nearest mode failed")
  
      e = 0
      r = sum_filter(i, footprint=fp, mode="constant", cval=0)
      self.assertAlmostEqual(r[0, 0], e, msg="constant mode failed")
  
      e = 9
      r = sum_filter(i, footprint=fp, mode="constant", cval=9)
      self.assertAlmostEqual(r[0, 0], e, msg="constant mode failed")
  
file_path: medpy/tests/filter_/image.py
imports: import unittest
  import numpy
  from medpy.filter.image import ssd, sls, sum_filter, average_filter
  from scipy.ndimage import gaussian_filter
label_desc: Use image node_id 5 for calling the TestMetrics obj's underlying member method code with example usage: obj.test_sum_filter() without return types