gtsam/python/gtsam/tests/test_HybridValues.py

43 lines
998 B
Python
Raw Normal View History

2022-08-19 05:50:20 +08:00
"""
2022-12-29 07:10:00 +08:00
GTSAM Copyright 2010-2022, Georgia Tech Research Corporation,
2022-08-19 05:50:20 +08:00
Atlanta, Georgia 30332-0415
All Rights Reserved
See LICENSE for the license information
Unit tests for Hybrid Values.
Author: Shangjie Xue
"""
# pylint: disable=invalid-name, no-name-in-module, no-member
from __future__ import print_function
import unittest
import gtsam
import numpy as np
from gtsam.symbol_shorthand import C, X
from gtsam.utils.test_case import GtsamTestCase
2022-12-29 07:10:00 +08:00
class TestHybridValues(GtsamTestCase):
2022-08-19 05:50:20 +08:00
"""Unit tests for HybridValues."""
def test_basic(self):
2022-12-29 07:10:00 +08:00
"""Test construction and basic methods of hybrid values."""
2022-08-19 05:50:20 +08:00
hv1 = gtsam.HybridValues()
2022-12-29 07:10:00 +08:00
hv1.insert(X(0), np.ones((3, 1)))
2022-08-19 05:50:20 +08:00
hv1.insert(C(0), 2)
hv2 = gtsam.HybridValues()
hv2.insert(C(0), 2)
2022-12-29 07:10:00 +08:00
hv2.insert(X(0), np.ones((3, 1)))
2022-08-19 05:50:20 +08:00
self.assertEqual(hv1.atDiscrete(C(0)), 2)
2022-12-29 07:10:00 +08:00
self.assertEqual(hv1.at(X(0))[0], np.ones((3, 1))[0])
2022-08-19 05:50:20 +08:00
if __name__ == "__main__":
unittest.main()