@@ -90,11 +90,16 @@ def test_two_data_points(self, cmp_report: MyComparisonReport, nccl_tr: TestRun)
9090 ["value" ],
9191 )
9292
93- assert len (table .columns ) == 3
93+ assert len (table .columns ) == 4
9494 assert len (table .rows ) == 3
9595 assert list (table .columns [0 ].cells ) == ["1" , "2" , "4" ]
9696 assert list (table .columns [1 ].cells ) == ["10" , "20" , "40" ]
9797 assert list (table .columns [2 ].cells ) == ["100" , "200" , "400" ]
98+ assert list (table .columns [3 ].cells ) == [
99+ ComparisonReport ._format_diff_cell (10 , 100 ),
100+ ComparisonReport ._format_diff_cell (20 , 200 ),
101+ ComparisonReport ._format_diff_cell (40 , 400 ),
102+ ]
98103
99104 def test_one_data_point_is_empty (self , cmp_report : MyComparisonReport , nccl_tr : TestRun ) -> None :
100105 table = cmp_report .create_table (
@@ -114,11 +119,72 @@ def test_one_data_point_is_empty(self, cmp_report: MyComparisonReport, nccl_tr:
114119 ["value" ],
115120 )
116121
117- assert len (table .columns ) == 3
122+ assert len (table .columns ) == 4
123+ assert table .columns [- 1 ].header == "diff\n value"
118124 assert len (table .rows ) == 3
119125 assert list (table .columns [0 ].cells ) == ["1" , "2" , "4" ]
120126 assert list (table .columns [1 ].cells ) == ["n/a" , "n/a" , "n/a" ]
121127 assert list (table .columns [2 ].cells ) == ["10" , "20" , "40" ]
128+ assert list (table .columns [3 ].cells ) == ["n/a" , "n/a" , "n/a" ]
129+
130+ def test_two_data_points_with_two_data_columns (self , cmp_report : MyComparisonReport , nccl_tr : TestRun ) -> None :
131+ table = cmp_report .create_table (
132+ GroupedTestRuns (
133+ name = "grp_name" ,
134+ items = [
135+ TRGroupItem (name = "item_name" , tr = nccl_tr ),
136+ TRGroupItem (name = "item_name2" , tr = nccl_tr ),
137+ ],
138+ ),
139+ [
140+ pd .DataFrame ({"size" : [1 ], "value1" : [10 ], "value2" : [5 ]}),
141+ pd .DataFrame ({"size" : [1 ], "value1" : [100 ], "value2" : [50 ]}),
142+ ],
143+ "title" ,
144+ ["size" ],
145+ ["value1" , "value2" ],
146+ )
147+
148+ assert len (table .columns ) == 7 # 1 info + 1 size + 2*2 data + 2 diff
149+ assert len (table .rows ) == 1
150+ assert list (table .columns [0 ].cells ) == ["1" ]
151+ assert list (table .columns [1 ].cells ) == ["10" ]
152+ assert list (table .columns [2 ].cells ) == ["100" ]
153+ assert list (table .columns [3 ].cells ) == [
154+ ComparisonReport ._format_diff_cell (10 , 100 ),
155+ ]
156+ assert list (table .columns [4 ].cells ) == ["5" ]
157+ assert list (table .columns [5 ].cells ) == ["50" ]
158+ assert list (table .columns [6 ].cells ) == [
159+ ComparisonReport ._format_diff_cell (5 , 50 ),
160+ ]
161+
162+ def test_three_data_points (self , cmp_report : MyComparisonReport , nccl_tr : TestRun ) -> None :
163+ table = cmp_report .create_table (
164+ GroupedTestRuns (
165+ name = "grp_name" ,
166+ items = [
167+ TRGroupItem (name = "item_name" , tr = nccl_tr ),
168+ TRGroupItem (name = "item_name2" , tr = nccl_tr ),
169+ TRGroupItem (name = "item_name3" , tr = nccl_tr ),
170+ ],
171+ ),
172+ [
173+ pd .DataFrame ({"size" : [1 ], "value" : [10 ]}),
174+ pd .DataFrame ({"size" : [1 ], "value" : [100 ]}),
175+ pd .DataFrame ({"size" : [1 ], "value" : [1000 ]}),
176+ ],
177+ "title" ,
178+ ["size" ],
179+ ["value" ],
180+ )
181+
182+ assert len (table .columns ) == 4 # 1 info + 3*1 data (NO diff)
183+ assert len (table .rows ) == 1
184+ assert list (table .columns [0 ].cells ) == ["1" ]
185+ assert list (table .columns [1 ].cells ) == ["10" ]
186+ assert list (table .columns [2 ].cells ) == ["100" ]
187+ assert list (table .columns [3 ].cells ) == ["1000" ]
122188
123189
124190def test_create_charts (cmp_report : MyComparisonReport , nccl_tr : TestRun ) -> None :
0 commit comments