def test_same_on_batch(self, device, dtype): torch.manual_seed(42) degrees = torch.tensor([[0, 30], [0, 30], [0, 30]]) res = random_rotation_generator3d( batch_size=2, degrees=degrees.to(device=device, dtype=dtype), same_on_batch=True ) expected = dict( yaw=torch.tensor([26.4681, 26.4681], device=device, dtype=dtype), pitch=torch.tensor([27.4501, 27.4501], device=device, dtype=dtype), roll=torch.tensor([11.4859, 11.4859], device=device, dtype=dtype), ) assert res.keys() == expected.keys() assert_allclose(res['yaw'], expected['yaw'], atol=1e-4, rtol=1e-4) assert_allclose(res['pitch'], expected['pitch'], atol=1e-4, rtol=1e-4) assert_allclose(res['roll'], expected['roll'], atol=1e-4, rtol=1e-4)
def test_same_on_batch(self, device, dtype): torch.manual_seed(42) degrees = torch.tensor([[0, 30], [0, 30], [0, 30]]) res = random_rotation_generator3d(batch_size=2, degrees=degrees.to(device=device, dtype=dtype), same_on_batch=True) expected = dict(yaw=torch.tensor([1.7446, 1.7446], device=device, dtype=dtype), pitch=torch.tensor([1.8873, 1.8873], device=device, dtype=dtype), roll=torch.tensor([3.7076, 3.7076], device=device, dtype=dtype)) assert res.keys() == expected.keys() assert_allclose(res['yaw'], expected['yaw'], atol=1e-4, rtol=1e-4) assert_allclose(res['pitch'], expected['pitch'], atol=1e-4, rtol=1e-4) assert_allclose(res['roll'], expected['roll'], atol=1e-4, rtol=1e-4)
def test_invalid_param_combinations(self, degrees, device, dtype): with pytest.raises(Exception): random_rotation_generator3d(batch_size=8, degrees=degrees.to(device=device, dtype=dtype))
def test_valid_param_combinations(self, batch_size, degrees, same_on_batch, device, dtype): random_rotation_generator3d(batch_size=batch_size, degrees=degrees.to(device=device, dtype=dtype), same_on_batch=same_on_batch)
def test_invalid_param_combinations(self, degrees, device, dtype): batch_size = 8 random_rotation_generator3d(batch_size=batch_size, degrees=degrees.to(device=device, dtype=dtype))