Skip to content

Commit 74fa386

Browse files
daguirre11D’Angelo Aguirre
andauthored
[python-package] Added test for plotting.ylim (#7142)
Co-authored-by: D’Angelo Aguirre <[email protected]>
1 parent 80ab6d3 commit 74fa386

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/python_package_test/test_plotting.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ 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+
102113
gbm2 = lgb.LGBMClassifier(n_estimators=10, num_leaves=3, verbose=-1, importance_type="gain")
103114
gbm2.fit(X_train, y_train)
104115

0 commit comments

Comments
 (0)