@@ -154,7 +154,9 @@ def test_plot_split_value_histogram(params, breast_cancer_split, train_data):
154
154
assert ax2 .patches [2 ].get_facecolor () == (0 , 0.5 , 0 , 1.0 ) # g
155
155
assert ax2 .patches [3 ].get_facecolor () == (0 , 0 , 1.0 , 1.0 ) # b
156
156
157
- with pytest .raises (ValueError ):
157
+ with pytest .raises (
158
+ ValueError , match = "Cannot plot split value histogram, because feature 0 was not used in splitting"
159
+ ):
158
160
lgb .plot_split_value_histogram (gbm0 , 0 ) # was not used in splitting
159
161
160
162
@@ -166,7 +168,7 @@ def test_plot_tree(breast_cancer_split):
166
168
gbm = lgb .LGBMClassifier (n_estimators = 10 , num_leaves = 3 , verbose = - 1 )
167
169
gbm .fit (X_train , y_train )
168
170
169
- with pytest .raises (IndexError ):
171
+ with pytest .raises (IndexError , match = "tree_index is out of range." ):
170
172
lgb .plot_tree (gbm , tree_index = 83 )
171
173
172
174
ax = lgb .plot_tree (gbm , tree_index = 3 , figsize = (15 , 8 ), show_info = ["split_gain" ])
@@ -184,7 +186,7 @@ def test_create_tree_digraph(tmp_path, breast_cancer_split):
184
186
gbm = lgb .LGBMClassifier (n_estimators = 10 , num_leaves = 3 , verbose = - 1 , monotone_constraints = constraints )
185
187
gbm .fit (X_train , y_train )
186
188
187
- with pytest .raises (IndexError ):
189
+ with pytest .raises (IndexError , match = "tree_index is out of range." ):
188
190
lgb .create_tree_digraph (gbm , tree_index = 83 )
189
191
190
192
graph = lgb .create_tree_digraph (
@@ -229,7 +231,7 @@ def test_tree_with_categories_below_max_category_values(tmp_path):
229
231
gbm = lgb .LGBMClassifier (** params )
230
232
gbm .fit (X_train , y_train )
231
233
232
- with pytest .raises (IndexError ):
234
+ with pytest .raises (IndexError , match = "tree_index is out of range." ):
233
235
lgb .create_tree_digraph (gbm , tree_index = 83 )
234
236
235
237
graph = lgb .create_tree_digraph (
@@ -274,7 +276,7 @@ def test_tree_with_categories_above_max_category_values(tmp_path):
274
276
gbm = lgb .LGBMClassifier (** params )
275
277
gbm .fit (X_train , y_train )
276
278
277
- with pytest .raises (IndexError ):
279
+ with pytest .raises (IndexError , match = "tree_index is out of range." ):
278
280
lgb .create_tree_digraph (gbm , tree_index = 83 )
279
281
280
282
graph = lgb .create_tree_digraph (
0 commit comments