@@ -99,6 +99,28 @@ def test_plot_importance(params, breast_cancer_split, train_data):
9999 with pytest .raises (TypeError , match = "xlim must be a tuple of 2 elements." ):
100100 lgb .plot_importance (gbm0 , title = None , xlabel = None , ylabel = None , xlim = "not a tuple" )
101101
102+ ax5 = lgb .plot_importance (gbm0 , title = None , xlabel = None , ylabel = None , ylim = (0 , 30 ))
103+ assert isinstance (ax5 , matplotlib .axes .Axes )
104+ assert ax5 .get_title () == ""
105+ assert ax5 .get_xlabel () == ""
106+ assert ax5 .get_ylabel () == ""
107+ assert ax5 .get_ylim () == (0 , 30 )
108+ assert len (ax5 .patches ) <= 30
109+
110+ with pytest .raises (TypeError , match = "ylim must be a tuple of 2 elements." ):
111+ lgb .plot_importance (gbm0 , title = None , xlabel = None , ylabel = None , ylim = "not a tuple" )
112+
113+ ax6 = lgb .plot_importance (gbm0 , title = None , xlabel = None , ylabel = None , figsize = (0 , 30 ))
114+ assert isinstance (ax6 , matplotlib .axes .Axes )
115+ assert ax6 .get_title () == ""
116+ assert ax6 .get_xlabel () == ""
117+ assert ax6 .get_ylabel () == ""
118+ assert list (ax6 .get_figure ().get_size_inches ()) == [0 , 30 ]
119+ assert len (ax6 .patches ) <= 30
120+
121+ with pytest .raises (TypeError , match = "figsize must be a tuple of 2 elements." ):
122+ lgb .plot_importance (gbm0 , title = None , xlabel = None , ylabel = None , figsize = "not a tuple" )
123+
102124 gbm2 = lgb .LGBMClassifier (n_estimators = 10 , num_leaves = 3 , verbose = - 1 , importance_type = "gain" )
103125 gbm2 .fit (X_train , y_train )
104126
0 commit comments