code
stringlengths
3
6.57k
res.keys()
expected.keys()
assert_allclose(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)
assert_allclose(res['center'], expected['center'], rtol=1e-4, atol=1e-4)
assert_allclose(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)
assert_allclose(res['angle'], expected['angle'], rtol=1e-4, atol=1e-4)
assert_allclose(res['sx'], expected['sx'], rtol=1e-4, atol=1e-4)
assert_allclose(res['sy'], expected['sy'], rtol=1e-4, atol=1e-4)
TestRandomRotationGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('degrees', [torch.tensor([0, 30])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, degrees, same_on_batch, device, dtype)
degrees.to(device=device, dtype=dtype)
pytest.mark.parametrize('degrees', [(torch.tensor(10)
torch.tensor([10])
torch.tensor([10, 20, 30])
test_invalid_param_combinations(self, degrees, device, dtype)
pytest.raises(Exception)
random_rotation_generator(batch_size=batch_size, degrees=degrees.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([10, 20])
degrees.to(device=device, dtype=dtype)
dict(degrees=torch.tensor([18.8227, 19.1500], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['degrees'], expected['degrees'])
test_same_on_batch(self, device, dtype)
torch.manual_seed(42)
torch.tensor([10, 20])
degrees.to(device=device, dtype=dtype)
dict(degrees=torch.tensor([18.8227, 18.8227], device=device, dtype=dtype)
res.keys()
expected.keys()
assert_allclose(res['degrees'], expected['degrees'])
TestRandomCropGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 2])
pytest.mark.parametrize('input_size', [(200, 200)
pytest.mark.parametrize('size', [(100, 100)
torch.tensor([50, 50])
pytest.mark.parametrize('resize_to', [None, (100, 100)
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, input_size, size, resize_to, same_on_batch, device, dtype)
isinstance(size, torch.Tensor)
size.repeat(batch_size, 1)
to(device=device, dtype=dtype)
torch.tensor([50, 50])
test_invalid_param_combinations(self, input_size, size, resize_to, device, dtype)
pytest.raises(Exception)
size.to(device=device, dtype=dtype)
isinstance(size, torch.Tensor)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([10, 20], device=device, dtype=dtype)
torch.tensor([[50, 60], [70, 80]], device=device, dtype=dtype)
torch.tensor([[100, 100], [100, 100]], device=device, dtype=torch.long)
res.keys()
expected.keys()
assert_allclose(res['src'], expected['src'])
assert_allclose(res['dst'], expected['dst'])
test_same_on_batch(self, device, dtype)
torch.manual_seed(42)
torch.tensor([10, 20], device=device, dtype=dtype)
torch.tensor([[50, 60], [70, 80]], device=device, dtype=dtype)
torch.tensor([[100, 100], [100, 100]], device=device, dtype=torch.long)
res.keys()
expected.keys()
assert_allclose(res['src'], expected['src'])
assert_allclose(res['dst'], expected['dst'])
TestRandomCropSizeGen(RandomGeneratorBaseTests)
pytest.mark.parametrize('batch_size', [0, 1, 8])
pytest.mark.parametrize('size', [(200, 200)
pytest.mark.parametrize('scale', [torch.tensor([.7, 1.3])
pytest.mark.parametrize('ratio', [torch.tensor([.9, 1.1])
pytest.mark.parametrize('same_on_batch', [True, False])
test_valid_param_combinations(self, batch_size, size, scale, ratio, same_on_batch, device, dtype)
scale.to(device=device, dtype=dtype)
ratio.to(device=device, dtype=dtype)
torch.tensor([.7, 1.3])
torch.tensor([.9, 1.1])
torch.tensor([.7, 1.3])
torch.tensor([.9, 1.1])
torch.tensor([.7])
torch.tensor([.9, 1.1])
torch.tensor([.7, 1.3, 1.5])
torch.tensor([.9, 1.1])
torch.tensor([.7, 1.3])
torch.tensor([.9])
torch.tensor([.7, 1.3])
torch.tensor([.9, 1.1, 1.3])
test_invalid_param_combinations(self, size, scale, ratio, device, dtype)
pytest.raises(Exception)
scale.to(device=device, dtype=dtype)
ratio.to(device=device, dtype=dtype)
test_random_gen(self, device, dtype)
torch.manual_seed(42)
torch.tensor([0.7, 1.3], device=device, dtype=dtype)
torch.tensor([0.9, 1.1], device=device, dtype=dtype)
res.keys()