Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_is_sim3(self):
r = lie.random_so3()
t = np.array([1, 2, 3])
s = 3
p = lie.sim3(r, t, s)
self.assertTrue(lie.is_sim3(p, s))
def test_so3_log_exp(self):
r = lie.random_so3()
self.assertTrue(lie.is_so3(r))
rotvec = lie.so3_log(r, return_angle_only=False)
self.assertTrue(np.allclose(r, lie.so3_exp(rotvec), atol=1e-6))
angle = lie.so3_log(r)
self.assertAlmostEqual(np.linalg.norm(rotvec), angle)
def random_se3_list(length):
return [lie.random_se3() for _ in range(length)]
def test_so3_from_se3(self):
p = lie.random_se3()
r = lie.so3_from_se3(p)
self.assertTrue(lie.is_so3(r))
def test_transform_sim3(self):
path = helpers.fake_path(10)
path_transformed = copy.deepcopy(path)
t = lie.sim3(r=lie.random_so3(), t=np.ones(3), s=1.234)
path_transformed.transform(t)
self.assertAlmostEqual(path_transformed.path_length,
path.path_length * 1.234)
def test_write_read_integrity(self):
result_out = Result()
result_out.add_np_array("test-array", np.ones(1000))
result_out.add_info({"name": "test", "number": 666})
result_out.add_trajectory("traj", helpers.fake_trajectory(1000, 0.1))
file_interface.save_res_file(self.mock_file, result_out)
result_in = file_interface.load_res_file(self.mock_file,
load_trajectories=True)
self.assertEqual(result_in, result_out)
def test_write_read_integrity(self):
traj_out = helpers.fake_trajectory(1000, 0.1)
self.assertTrue(traj_out.check())
file_interface.write_tum_trajectory_file(self.mock_file, traj_out)
self.mock_file.seek(0)
traj_in = file_interface.read_tum_trajectory_file(self.mock_file)
self.assertIsInstance(traj_in, PoseTrajectory3D)
self.assertTrue(traj_in.check())
self.assertTrue(traj_out == traj_in)
def test_with_bom(self):
tmp_file = tempfile.NamedTemporaryFile(delete=False)
with open(tmp_file.name, 'wb') as f:
f.write(b"\xef\xbb\xbf")
self.assertTrue(file_interface.has_utf8_bom(tmp_file.name))
def test_write_read_integrity(self):
import rosbag
tmp_file = tempfile.NamedTemporaryFile(delete=False)
bag_out = rosbag.Bag(tmp_file.name, 'w')
traj_out = helpers.fake_trajectory(1000, 0.1)
self.assertTrue(traj_out.check())
file_interface.write_bag_trajectory(bag_out, traj_out, "/test",
frame_id="map")
bag_out.close()
bag_in = rosbag.Bag(tmp_file.name, 'r')
traj_in = file_interface.read_bag_trajectory(bag_in, "/test")
self.assertIsInstance(traj_in, PoseTrajectory3D)
self.assertTrue(traj_in.check())
self.assertTrue(traj_out == traj_in)
self.assertEqual(traj_in.meta["frame_id"], "map")
def test_too_many_columns(self):
self.mock_file.write(u"1 2 3 4 5 6 7 8 9 10 11 12 13")
self.mock_file.seek(0)
with self.assertRaises(file_interface.FileInterfaceException):
file_interface.read_kitti_poses_file(self.mock_file)