test_dsf_map.py
Go to the documentation of this file.
1 """
2 GTSAM Copyright 2010-2019, 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 Disjoint Set Forest.
9 Author: Frank Dellaert & Varun Agrawal
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 from gtsam.utils.test_case import GtsamTestCase
19 
20 
22  """Tests for DSFMap."""
23 
24  def test_all(self):
25  """Test everything in DFSMap."""
26  def key(index_pair):
27  return index_pair.i(), index_pair.j()
28 
29  dsf = gtsam.DSFMapIndexPair()
30  pair1 = gtsam.IndexPair(1, 18)
31  self.assertEqual(key(dsf.find(pair1)), key(pair1))
32  pair2 = gtsam.IndexPair(2, 2)
33 
34  # testing the merge feature of dsf
35  dsf.merge(pair1, pair2)
36  self.assertEqual(key(dsf.find(pair1)), key(dsf.find(pair2)))
37 
38  def test_sets(self):
39  from gtsam import IndexPair
40  dsf = gtsam.DSFMapIndexPair()
41  dsf.merge(IndexPair(0, 1), IndexPair(1,2))
42  dsf.merge(IndexPair(0, 1), IndexPair(3,4))
43  dsf.merge(IndexPair(4,5), IndexPair(6,8))
44  sets = dsf.sets()
45 
46  for i in sets:
47  s = sets[i]
48  for val in gtsam.IndexPairSetAsArray(s):
49  val.i()
50  val.j()
51 
52 
53 if __name__ == '__main__':
54  unittest.main()
IndexPairVector IndexPairSetAsArray(IndexPairSet &set)
Definition: DSFMap.h:128
Small utility class for representing a wrappable pairs of ints.
Definition: DSFMap.h:117


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:46:03