Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.skip(reason="turn off all jit for a while")
def test_jit(self, device):
op = kornia.quaternion_exp_to_log
op_script = torch.jit.script(op)
quaternion = torch.tensor([0., 0., 1., 0.]).to(device)
actual = op_script(quaternion)
expected = op(quaternion)
assert_allclose(actual, expected)
def test_jit(self, device):
op = kornia.quaternion_exp_to_log
op_script = torch.jit.script(op)
quaternion = torch.tensor([0., 0., 1., 0.]).to(device)
actual = op_script(quaternion)
expected = op(quaternion)
assert_allclose(actual, expected)
def test_pi_quaternion(self, device):
quaternion_exp = torch.tensor([1., 0., 0., 0.]).to(device)
expected = torch.tensor([kornia.pi / 2, 0., 0.]).to(device)
assert_allclose(kornia.quaternion_exp_to_log(quaternion_exp), expected)
def test_unit_quaternion(self, device):
quaternion_exp = torch.tensor([0., 0., 0., 1.]).to(device)
expected = torch.tensor([0., 0., 0.]).to(device)
assert_allclose(kornia.quaternion_exp_to_log(quaternion_exp), expected)
def test_pi_quaternion(self, device):
quaternion_exp = torch.tensor([1., 0., 0., 0.]).to(device)
expected = torch.tensor([kornia.pi / 2, 0., 0.]).to(device)
assert_allclose(kornia.quaternion_exp_to_log(quaternion_exp), expected)
def test_back_and_forth(self, device):
quaternion_exp = torch.tensor([1., 0., 0., 0.]).to(device)
quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp)
quaternion_exp_hat = kornia.quaternion_log_to_exp(quaternion_log)
assert_allclose(quaternion_exp, quaternion_exp_hat)
def test_back_and_forth(self, device):
quaternion_exp = torch.tensor([1., 0., 0., 0.]).to(device)
quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp)
quaternion_exp_hat = kornia.quaternion_log_to_exp(quaternion_log)
assert_allclose(quaternion_exp, quaternion_exp_hat)
def test_gradcheck(self, device):
quaternion = torch.tensor([1., 0., 0., 0.]).to(device)
quaternion = tensor_to_gradcheck_var(quaternion)
# evaluate function gradient
assert gradcheck(kornia.quaternion_exp_to_log, (quaternion,),
raise_exception=True)
def test_unit_quaternion(self, device):
quaternion_exp = torch.tensor([0., 0., 0., 1.]).to(device)
expected = torch.tensor([0., 0., 0.]).to(device)
assert_allclose(kornia.quaternion_exp_to_log(quaternion_exp), expected)