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 numpy as np
18 from gtsam.symbol_shorthand import C, X
19 from gtsam.utils.test_case import GtsamTestCase
20 
21 import gtsam
22 
23 
25  """Unit tests for HybridValues."""
26 
27  def test_basic(self):
28  """Test construction and basic methods of hybrid values."""
29 
30  hv1 = gtsam.HybridValues()
31  hv1.insert(X(0), np.ones((3, 1)))
32  hv1.insert(C(0), 2)
33 
34  hv2 = gtsam.HybridValues()
35  hv2.insert(C(0), 2)
36  hv2.insert(X(0), np.ones((3, 1)))
37 
38  self.assertEqual(hv1.atDiscrete(C(0)), 2)
39  self.assertEqual(hv1.at(X(0))[0], np.ones((3, 1))[0])
40 
41 
42 if __name__ == "__main__":
43  unittest.main()
gtsam::HybridValues
Definition: HybridValues.h:37
test_HybridValues.TestHybridValues.test_basic
def test_basic(self)
Definition: test_HybridValues.py:27
gtsam::symbol_shorthand
Definition: inference/Symbol.h:147
X
#define X
Definition: icosphere.cpp:20
gtsam::utils.test_case
Definition: test_case.py:1
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
test_HybridValues.TestHybridValues
Definition: test_HybridValues.py:24
gtsam::utils.test_case.GtsamTestCase
Definition: test_case.py:15


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:39:27