2 See LICENSE for the license information
4 Unit tests for Graphviz formatting of NonlinearFactorGraph.
5 Author: senselessDev (contact by mentioning on GitHub, e.g. in PR#1059)
20 """Tests for saving NonlinearFactorGraph to GraphViz format."""
27 np.array([0.2, 0.2, 0.1]))
28 self.
graph.
add(gtsam.BetweenFactorPose2(0, 1, odometry, odometryNoise))
29 self.
graph.
add(gtsam.BetweenFactorPose2(1, 2, odometry, odometryNoise))
37 """Test with default GraphvizFormatting"""
38 expected_result =
"""\
42 var0[label="0", pos="0,0!"];
43 var1[label="1", pos="0,2!"];
44 var2[label="2", pos="0,4!"];
46 factor0[label="", shape=point];
49 factor1[label="", shape=point];
56 textwrap.dedent(expected_result))
59 """Test with user-defined GraphvizFormatting swapping x and y"""
60 expected_result =
"""\
64 var0[label="0", pos="0,0!"];
65 var1[label="1", pos="2,0!"];
66 var2[label="2", pos="4,0!"];
68 factor0[label="", shape=point];
71 factor1[label="", shape=point];
78 graphviz_formatting.paperHorizontalAxis = gtsam.GraphvizFormatting.Axis.X
79 graphviz_formatting.paperVerticalAxis = gtsam.GraphvizFormatting.Axis.Y
81 writer=graphviz_formatting),
82 textwrap.dedent(expected_result))
85 """Test with user-defined GraphvizFormatting without factor points"""
86 expected_result =
"""\
90 var0[label="0", pos="0,0!"];
91 var1[label="1", pos="0,2!"];
92 var2[label="2", pos="0,4!"];
100 graphviz_formatting.plotFactorPoints =
False
103 writer=graphviz_formatting),
104 textwrap.dedent(expected_result))
107 """Test with user-defined GraphvizFormatting for width and height"""
108 expected_result =
"""\
112 var0[label="0", pos="0,0!"];
113 var1[label="1", pos="0,2!"];
114 var2[label="2", pos="0,4!"];
116 factor0[label="", shape=point];
119 factor1[label="", shape=point];
126 graphviz_formatting.figureWidthInches = 20
127 graphviz_formatting.figureHeightInches = 10
130 writer=graphviz_formatting),
131 textwrap.dedent(expected_result))
134 if __name__ ==
"__main__":