Commit ff88dbaf authored by F-G Fernandez's avatar F-G Fernandez Committed by Francisco Massa
Browse files

test: Updated asserts in test_transforms_video (#1498)

Updated all raw asserts to corresponding unittest.TestCase.assert. See #1483
parent a7d6fa6d
...@@ -25,8 +25,8 @@ class TestVideoTransforms(unittest.TestCase): ...@@ -25,8 +25,8 @@ class TestVideoTransforms(unittest.TestCase):
transforms.ToTensorVideo(), transforms.ToTensorVideo(),
transforms.RandomCropVideo((oheight, owidth)), transforms.RandomCropVideo((oheight, owidth)),
])(clip) ])(clip)
assert result.size(2) == oheight self.assertEqual(result.size(2), oheight)
assert result.size(3) == owidth self.assertEqual(result.size(3), owidth)
transforms.RandomCropVideo((oheight, owidth)).__repr__() transforms.RandomCropVideo((oheight, owidth)).__repr__()
...@@ -41,8 +41,8 @@ class TestVideoTransforms(unittest.TestCase): ...@@ -41,8 +41,8 @@ class TestVideoTransforms(unittest.TestCase):
transforms.ToTensorVideo(), transforms.ToTensorVideo(),
transforms.RandomResizedCropVideo((oheight, owidth)), transforms.RandomResizedCropVideo((oheight, owidth)),
])(clip) ])(clip)
assert result.size(2) == oheight self.assertEqual(result.size(2), oheight)
assert result.size(3) == owidth self.assertEqual(result.size(3), owidth)
transforms.RandomResizedCropVideo((oheight, owidth)).__repr__() transforms.RandomResizedCropVideo((oheight, owidth)).__repr__()
...@@ -110,13 +110,13 @@ class TestVideoTransforms(unittest.TestCase): ...@@ -110,13 +110,13 @@ class TestVideoTransforms(unittest.TestCase):
mean = [clip[c].mean().item() for c in range(channels)] mean = [clip[c].mean().item() for c in range(channels)]
std = [clip[c].std().item() for c in range(channels)] std = [clip[c].std().item() for c in range(channels)]
normalized = transforms.NormalizeVideo(mean, std)(clip) normalized = transforms.NormalizeVideo(mean, std)(clip)
assert samples_from_standard_normal(normalized) self.assertTrue(samples_from_standard_normal(normalized))
random.setstate(random_state) random.setstate(random_state)
# Checking the optional in-place behaviour # Checking the optional in-place behaviour
tensor = torch.rand((3, 128, 16, 16)) tensor = torch.rand((3, 128, 16, 16))
tensor_inplace = transforms.NormalizeVideo((0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True)(tensor) tensor_inplace = transforms.NormalizeVideo((0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True)(tensor)
assert torch.equal(tensor, tensor_inplace) self.assertTrue(torch.equal(tensor, tensor_inplace))
transforms.NormalizeVideo((0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True).__repr__() transforms.NormalizeVideo((0.5, 0.5, 0.5), (0.5, 0.5, 0.5), inplace=True).__repr__()
...@@ -152,7 +152,7 @@ class TestVideoTransforms(unittest.TestCase): ...@@ -152,7 +152,7 @@ class TestVideoTransforms(unittest.TestCase):
p_value = stats.binom_test(num_horizontal, num_samples, p=0.5) p_value = stats.binom_test(num_horizontal, num_samples, p=0.5)
random.setstate(random_state) random.setstate(random_state)
assert p_value > 0.0001 self.assertGreater(p_value, 0.0001)
num_samples = 250 num_samples = 250
num_horizontal = 0 num_horizontal = 0
...@@ -163,7 +163,7 @@ class TestVideoTransforms(unittest.TestCase): ...@@ -163,7 +163,7 @@ class TestVideoTransforms(unittest.TestCase):
p_value = stats.binom_test(num_horizontal, num_samples, p=0.7) p_value = stats.binom_test(num_horizontal, num_samples, p=0.7)
random.setstate(random_state) random.setstate(random_state)
assert p_value > 0.0001 self.assertGreater(p_value, 0.0001)
transforms.RandomHorizontalFlipVideo().__repr__() transforms.RandomHorizontalFlipVideo().__repr__()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment