@@ -63,6 +63,28 @@ def test_content(self):
6363 self .assertTrue (os .path .exists (os .path .join (tempdir , "metric4_raw.csv" )))
6464 self .assertTrue (os .path .exists (os .path .join (tempdir , "metric4_summary.csv" )))
6565
66+ def test_multi_metric_details_headers (self ):
67+ with tempfile .TemporaryDirectory () as tempdir :
68+ write_metrics_reports (
69+ save_dir = Path (tempdir ),
70+ images = ["img1" , "img2" ],
71+ metrics = None ,
72+ metric_details = {
73+ "m1" : torch .tensor ([[1 , 2 , 3 ], [4 , 5 , 6 ]]),
74+ "m2" : torch .tensor ([[7 , 8 ], [9 , 10 ]]),
75+ "m3" : torch .tensor ([[11 , 12 , 13 , 14 ], [15 , 16 , 17 , 18 ]]),
76+ },
77+ summary_ops = None ,
78+ deli = "," ,
79+ output_type = "csv" ,
80+ )
81+ for name , nclass in [("m1" , 3 ), ("m2" , 2 ), ("m3" , 4 )]:
82+ path = os .path .join (tempdir , f"{ name } _raw.csv" )
83+ self .assertTrue (os .path .exists (path ))
84+ with open (path ) as f :
85+ header = f .readline ().strip ().split ("," )
86+ self .assertEqual (header , ["filename" ] + [f"class{ i } " for i in range (nclass )] + ["mean" ])
87+
6688
6789if __name__ == "__main__" :
6890 unittest .main ()
0 commit comments