test_HybridValues.py
Go to the documentation of this file.
1 """
2 GTSAM Copyright 2010-2022, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
4 All Rights Reserved
5 
6 See LICENSE for the license information
7 
8 Unit tests for Hybrid Values.
9 Author: Shangjie Xue
10 """
11 # pylint: disable=invalid-name, no-name-in-module, no-member
12 
13 from __future__ import print_function
14 
15 import unittest
16 
17 import gtsam
18 import numpy as np
19 from gtsam.symbol_shorthand import C, X
20 from gtsam.utils.test_case import GtsamTestCase
21 
22 
24  """Unit tests for HybridValues."""
25 
26  def test_basic(self):
27  """Test construction and basic methods of hybrid values."""
28 
29  hv1 = gtsam.HybridValues()
30  hv1.insert(X(0), np.ones((3, 1)))
31  hv1.insert(C(0), 2)
32 
33  hv2 = gtsam.HybridValues()
34  hv2.insert(C(0), 2)
35  hv2.insert(X(0), np.ones((3, 1)))
36 
37  self.assertEqual(hv1.atDiscrete(C(0)), 2)
38  self.assertEqual(hv1.at(X(0))[0], np.ones((3, 1))[0])
39 
40 
41 if __name__ == "__main__":
42  unittest.main()
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
#define X
Definition: icosphere.cpp:20


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:45