Esempio n. 1
0
 def test_bkg_width_positive_on_3d_cube(self):
     img = np.array([[1, 2, 2, 2, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1],
                     [1, 2, 2, 2, 1], [1, 2, 2, 2, 1]])
     cube = np.outer(np.arange(5), img).reshape(5, 5, 5)
     med_1 = np.arange(5)
     med_2 = 2 * np.arange(5)
     assert np.all(get_bkg_level(cube, +1) == med_1)
     assert np.all(get_bkg_level(cube, +2) == med_2)
Esempio n. 2
0
 def test_bkg_width_zero_on_3d_cube(self):
     cube = np.random.rand(5, 5, 5)
     zeromed = np.zeros(cube.shape[0])
     assert np.all(get_bkg_level(cube, 0) == zeromed)
Esempio n. 3
0
 def test_bkg_width_negative_on_3d_cube(self):
     cube = np.random.rand(5, 5, 5)
     med = np.array([np.median(cube[i, :, :]) for i in np.arange(5)])
     assert np.all(get_bkg_level(cube, -1) == med)
Esempio n. 4
0
 def test_bkg_width_positive_on_2d_image(self):
     img = np.array([[1, 2, 2, 2, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1],
                     [1, 2, 2, 2, 1], [1, 2, 2, 2, 1]])
     assert get_bkg_level(img, 1) == 1
     assert get_bkg_level(img, 2) == 2
Esempio n. 5
0
 def test_bkg_width_zero_on_2d_image(self):
     img = np.random.rand(5, 5)
     assert get_bkg_level(img, 0) == 0
Esempio n. 6
0
 def test_bkg_width_negative_on_2d_image(self):
     img = np.random.rand(5, 5)
     assert get_bkg_level(img, -1) == np.median(img)
Esempio n. 7
0
 def test_bkg_width_error_on_1d_obj(self):
     obj = np.random.rand(10)
     with pytest.raises(ValueError):
         get_bkg_level(obj, -1)