code
stringlengths
3
6.57k
test_same_on_batch(self, device, dtype)
TestRandomMotionBlur(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('kernel_size', [3, (3, 5)
pytest.mark.parametrize('angle', [torch.tensor([10, 30])
pytest.mark.parametrize('direction', [torch.tensor([-1, -1])
torch.tensor([1, 1])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, kernel_size, angle, direction, same_on_batch, device, dtype)
angle.to(device=device, dtype=dtype)
direction.to(device=device, dtype=dtype)
torch.tensor([30, 100])
torch.tensor([-1, 1])
torch.tensor([30, 100])
torch.tensor([-1, 1])
torch.tensor([30, 100])
torch.tensor([-1, 1])
torch.tensor([30, 100])
torch.tensor([-2, 1])
torch.tensor([30, 100])
torch.tensor([-1, 2])
test_invalid_param_combinations(self, kernel_size, angle, direction, device, dtype)
pytest.raises(Exception)
angle.to(device=device, dtype=dtype)
direction.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([30, 90])
torch.tensor([-1, 1])
angle.to(device=device, dtype=dtype)
direction.to(device=device, dtype=dtype)
torch.tensor([3, 3], device=device, dtype=torch.int32)
torch.tensor([82.9362, 84.9002], device=device, dtype=dtype)
torch.tensor([-0.2343, 0.9186], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)
assert_allclose(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)
assert_allclose(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)
test_same_on_batch(self, device, dtype)
torch.manual_seed(42)
torch.tensor([30, 90])
torch.tensor([-1, 1])
angle.to(device=device, dtype=dtype)
direction.to(device=device, dtype=dtype)
torch.tensor([3, 3], device=device, dtype=torch.int32)
torch.tensor([82.9362, 82.9362], device=device, dtype=dtype)
torch.tensor([0.8300, 0.8300], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)
assert_allclose(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)
assert_allclose(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)
TestRandomSolarizeGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('thresholds', [torch.tensor([0, 1])
torch.tensor([0.4, 0.6])
pytest.mark.parametrize('additions', [torch.tensor([-0.5, 0.5])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, thresholds, additions, same_on_batch, device, dtype)
thresholds.to(device=device, dtype=dtype)
additions.to(device=device, dtype=dtype)
torch.tensor([0, 2])
torch.tensor([-0.5, 0.5])
torch.tensor([-1, 1])
torch.tensor([-0.5, 0.5])
torch.tensor([-0.5, 0.5])
torch.tensor([0, 1])
torch.tensor([-0.5, 1])
torch.tensor([0, 1])
torch.tensor([-1, 0.5])
torch.tensor([0, 1])
test_invalid_param_combinations(self, thresholds, additions, device, dtype)
pytest.raises(Exception)
thresholds.to(device=device, dtype=dtype)
additions.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([0, 1], device=device, dtype=dtype)
torch.tensor([-0.5, 0.5], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['thresholds_factor'], expected['thresholds_factor'], rtol=1e-4, atol=1e-4)
assert_allclose(res['additions_factor'], expected['additions_factor'], rtol=1e-4, atol=1e-4)
test_same_on_batch(self, device, dtype)
torch.manual_seed(42)
torch.tensor([0, 1], device=device, dtype=dtype)
torch.tensor([-0.5, 0.5], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['thresholds_factor'], expected['thresholds_factor'], rtol=1e-4, atol=1e-4)
assert_allclose(res['additions_factor'], expected['additions_factor'], rtol=1e-4, atol=1e-4)
TestRandomPosterizeGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('bits', [torch.tensor([0, 8])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, bits, same_on_batch, device, dtype)
bits.to(device=device, dtype=dtype)
torch.tensor([-1, 1])
torch.tensor([0, 9])