gtsam/python/gtsam/tests/test_dataset.py

46 lines
1.2 KiB
Python
Raw Normal View History

2019-03-14 10:47:23 +08:00
"""
GTSAM Copyright 2010-2019, Georgia Tech Research Corporation,
Atlanta, Georgia 30332-0415
All Rights Reserved
See LICENSE for the license information
Unit tests for testing dataset access.
2019-03-21 05:35:53 +08:00
Author: Frank Dellaert & Duy Nguyen Ta (Python)
2019-03-14 10:47:23 +08:00
"""
2019-03-14 13:25:06 +08:00
# pylint: disable=invalid-name, no-name-in-module, no-member
2019-03-14 10:47:23 +08:00
from __future__ import print_function
import unittest
import gtsam
2020-08-18 23:02:35 +08:00
from gtsam import BetweenFactorPose3
2019-03-21 05:35:53 +08:00
from gtsam.utils.test_case import GtsamTestCase
2019-03-14 10:47:23 +08:00
2019-03-21 05:35:53 +08:00
class TestDataset(GtsamTestCase):
2019-03-14 13:25:06 +08:00
"""Tests for datasets.h wrapper."""
2019-03-14 10:47:23 +08:00
def setUp(self):
2019-03-14 13:25:06 +08:00
"""Get some common paths."""
self.pose3_example_g2o_file = gtsam.findExampleDataFile(
"pose3example.txt")
2019-03-14 10:47:23 +08:00
2019-03-14 13:25:06 +08:00
def test_readG2o3D(self):
"""Test reading directly into factor graph."""
2019-03-14 10:47:23 +08:00
is3D = True
2019-03-14 13:25:06 +08:00
graph, initial = gtsam.readG2o(self.pose3_example_g2o_file, is3D)
2019-03-14 10:47:23 +08:00
self.assertEqual(graph.size(), 6)
self.assertEqual(initial.size(), 5)
2019-03-14 13:25:06 +08:00
def test_parse3Dfactors(self):
"""Test parsing into data structure."""
factors = gtsam.parse3DFactors(self.pose3_example_g2o_file)
2020-08-18 23:02:35 +08:00
self.assertEqual(len(factors), 6)
self.assertIsInstance(factors[0], BetweenFactorPose3)
2019-03-14 13:25:06 +08:00
2019-03-14 10:47:23 +08:00
if __name__ == '__main__':
unittest.main()