def test_add_layer2image_int(): grid2d = np.zeros((7, 7)) x_pos, y_pos = 4, 1 kernel = np.ones((3, 3)) added = image_util.add_layer2image_int(grid2d, x_pos, y_pos, kernel) print(added) assert added[0, 0] == 0 assert added[0, 3] == 1 added = image_util.add_layer2image_int(grid2d, x_pos + 10, y_pos, kernel) print(added) npt.assert_almost_equal(grid2d, added, decimal=9)
def test_raise(self): with self.assertRaises(ValueError): grid2d = np.zeros((7, 7)) x_pos, y_pos = 4, 1 kernel = np.ones((2, 2)) added = image_util.add_layer2image_int(grid2d, x_pos, y_pos, kernel) with self.assertRaises(ValueError): image = np.ones((5, 5)) image_util.re_size(image, factor=2) with self.assertRaises(ValueError): image = np.ones((5, 5)) image_util.re_size(image, factor=0.5) with self.assertRaises(ValueError): image = np.ones((5, 5)) image_util.cut_edges(image, numPix=7) with self.assertRaises(ValueError): image = np.ones((5, 6)) image_util.cut_edges(image, numPix=3) with self.assertRaises(ValueError): image = np.ones((5, 5)) image_util.cut_edges(image, numPix=2)