8000 MAINT removed close_figure helper (#13730) · marcelobeckmann/scikit-learn@b3ad764 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3ad764

Browse files
NicolasHugmarcelobeckmann
authored andcommitted
MAINT removed close_figure helper (scikit-learn#13730)
1 parent ddf9022 commit b3ad764

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

sklearn/inspection/tests/test_partial_dependence.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from sklearn.utils.testing import assert_allclose
2929
from sklearn.utils.testing import assert_array_equal
3030
from sklearn.utils.testing import if_matplotlib
31-
from sklearn.utils.testing import close_figure
3231

3332

3433
# toy sample
@@ -437,7 +436,7 @@ def test_plot_partial_dependence():
437436
assert len(axs) == 3
438437
assert all(ax.has_data for ax in axs)
439438

440-
close_figure()
439+
plt.close('all')
441440

442441

443442
@if_matplotlib
@@ -471,7 +470,7 @@ def test_plot_partial_dependence_multiclass():
471470
assert len(axs) == 2
472471
assert all(ax.has_data for ax in axs)
473472

474-
close_figure()
473+
plt.close('all')
475474

476475

477476
@if_matplotlib
@@ -499,7 +498,7 @@ def test_plot_partial_dependence_multioutput():
499498
assert len(axs) == 2
500499
assert all(ax.has_data for ax in axs)
501500

502-
close_figure()
501+
plt.close('all')
503502

504503

505504
@if_matplotlib
@@ -533,13 +532,14 @@ def test_plot_partial_dependence_multioutput():
533532
@pytest.mark.filterwarnings('ignore:Default solver will be changed ') # 0.22
534533
@pytest.mark.filterwarnings('ignore:Default multi_class will be') # 0.22
535534
def test_plot_partial_dependence_error(data, params, err_msg):
535+
import matplotlib.pyplot as plt # noqa
536536
X, y = data
537537
estimator = LinearRegression().fit(X, y)
538538

539539
with pytest.raises(ValueError, match=err_msg):
540540
plot_partial_dependence(estimator, X, **params)
541541

542-
close_figure()
542+
plt.close()
543543

544544

545545
@if_matplotlib
@@ -559,4 +559,4 @@ def test_plot_partial_dependence_fig():
559559

560560
assert plt.gcf() is fig
561561

562-
close_figure()
562+
plt.close()

sklearn/utils/testing.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -970,21 +970,3 @@ def check_docstring_parameters(func, doc=None, ignore=None, class_name=None):
970970
if n1 != n2:
971971
incorrect += [func_name + ' ' + n1 + ' != ' + n2]
972972
return incorrect
973-
974-
975-
def close_figure(fig=None):
976-
"""Close a matplotlibt figure.
977-
978-
Parameters
979-
----------
980-
fig : int or str or Figure, optional (default=None)
981-
The figure, figure number or figure name to close. If ``None``, all
982-
current figures are closed.
983-
"""
984-
from matplotlib.pyplot import get_fignums, close as _close # noqa
985-
986-
if fig is None:
987-
for fig in get_fignums():
988-
_close(fig)
989-
else:
990-
_close(fig)

0 commit comments

Comments
 (0)
0