@@ -843,6 +843,24 @@ def test_data_type(self):
843
843
transform_cfg = cfg ['quantization' ]['calibration' ]['dataloader' ]['transform' ]['BilinearImagenet' ]
844
844
self .assertTrue (isinstance (transform_cfg ['mean_value' ], list ))
845
845
846
+ def test_deep_set (self ):
847
+ from neural_compressor .conf .dotdict import DotDict , deep_set
848
+ cfg = {'evaluation' : {'accuracy' : {}}}
849
+ dot_cfg = DotDict (cfg )
850
+ deep_set (dot_cfg , 'evaluation.accuracy.metric' , 'iou' )
851
+ deep_set (dot_cfg , 'evaluation.accuracy.multi_metrics.weight' , [0.1 , 0 ,9 ])
852
+ deep_set (dot_cfg , 'evaluation.accuracy.multi_metrics.mAP.anno_path' , 'anno_path_test' )
853
+ self .assertTrue (dot_cfg .evaluation == dot_cfg ['evaluation' ])
854
+ self .assertTrue (dot_cfg .evaluation .accuracy == dot_cfg ['evaluation' ]['accuracy' ])
855
+ self .assertTrue (dot_cfg .evaluation .accuracy .metric == dot_cfg ['evaluation' ]['accuracy' ]['metric' ])
856
+ self .assertTrue (dot_cfg .evaluation .accuracy .multi_metrics == dot_cfg ['evaluation' ]['accuracy' ]['multi_metrics' ])
857
+ self .assertTrue (dot_cfg .evaluation .accuracy .multi_metrics .weight == [0.1 , 0 ,9 ])
858
+ self .assertTrue (dot_cfg .evaluation .accuracy .multi_metrics .mAP .anno_path == 'anno_path_test' )
859
+ multi_metrics1 = dot_cfg .evaluation .accuracy .multi_metrics
860
+ multi_metrics2 = dot_cfg ['evaluation' ]['accuracy' ]['multi_metrics' ]
861
+ self .assertTrue (multi_metrics1 == multi_metrics2 )
862
+ self .assertTrue (list (multi_metrics1 .keys ()) == ['weight' , 'mAP' ])
863
+
846
864
847
865
if __name__ == "__main__" :
848
866
unittest .main ()
0 commit comments