2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
6 See LICENSE for the license information
8 Unit tests for Disjoint Set Forest.
9 Author: Frank Dellaert & Varun Agrawal & John Lambert
13 from __future__
import print_function
16 from typing
import Tuple
18 from gtsam
import DSFMapIndexPair, IndexPair, IndexPairSetAsArray
23 """Tests for DSFMap."""
26 """Test everything in DFSMap."""
28 def key(index_pair) -> Tuple[int, int]:
29 return index_pair.i(), index_pair.j()
33 self.assertEqual(
key(dsf.find(pair1)),
key(pair1))
37 dsf.merge(pair1, pair2)
38 self.assertEqual(
key(dsf.find(pair1)),
key(dsf.find(pair2)))
41 """Ensure that pairs are merged correctly during Union-Find.
43 An IndexPair (i,k) representing a unique key might represent the
44 k'th detected keypoint in image i. For the data below, merging such
45 measurements into feature tracks across frames should create 2 distinct sets.
59 set_keys.append((val.i(), val.j()))
60 merged_sets.add(
tuple(set_keys))
64 ((0, 1), (1, 2), (3, 4)),
68 assert expected_sets == merged_sets
71 if __name__ ==
"__main__":