def test_same_result(self, im_shape, input_type): im = self.get_data(im_shape, input_type) alpha = [0.5, 0.8] t = RandGibbsNoise(1.0, alpha) t.set_random_state(42) out1 = t(deepcopy(im)) t.set_random_state(42) out2 = t(deepcopy(im)) assert_allclose(out1, out2, rtol=1e-7, atol=1e-2, type_test="tensor")
def test_same_result(self, im_shape, input_type): im = self.get_data(im_shape, input_type) alpha = [0.5, 0.8] t = RandGibbsNoise(1.0, alpha) t.set_random_state(42) out1 = t(deepcopy(im)) t.set_random_state(42) out2 = t(deepcopy(im)) torch.testing.assert_allclose(out1, out2, rtol=1e-7, atol=0) self.assertIsInstance(out1, type(im))
def test_same_result(self, im_shape, as_tensor_output, as_tensor_input): im = self.get_data(im_shape, as_tensor_input) alpha = [0.5, 0.8] t = RandGibbsNoise(1.0, alpha, as_tensor_output) t.set_random_state(42) out1 = t(deepcopy(im)) t.set_random_state(42) out2 = t(deepcopy(im)) np.testing.assert_allclose(out1, out2) self.assertIsInstance(out1, torch.Tensor if as_tensor_output else np.ndarray)