Skip to content

[MRG] removed close_figure helper #13730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sklearn/inspection/tests/test_partial_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from sklearn.utils.testing import assert_allclose
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import if_matplotlib
from sklearn.utils.testing import close_figure


# toy sample
Expand Down Expand Up @@ -437,7 +436,7 @@ def test_plot_partial_dependence():
assert len(axs) == 3
assert all(ax.has_data for ax in axs)

close_figure()
plt.close('all')


@if_matplotlib
Expand Down Expand Up @@ -471,7 +470,7 @@ def test_plot_partial_dependence_multiclass():
assert len(axs) == 2
assert all(ax.has_data for ax in axs)

close_figure()
plt.close('all')


@if_matplotlib
Expand Down Expand Up @@ -499,7 +498,7 @@ def test_plot_partial_dependence_multioutput():
assert len(axs) == 2
assert all(ax.has_data for ax in axs)

close_figure()
plt.close('all')


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

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

close_figure()
plt.close()


@if_matplotlib
Expand All @@ -559,4 +559,4 @@ def test_plot_partial_dependence_fig():

assert plt.gcf() is fig

close_figure()
plt.close()
18 changes: 0 additions & 18 deletions sklearn/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,21 +970,3 @@ def check_docstring_parameters(func, doc=None, ignore=None, class_name=None):
if n1 != n2:
incorrect += [func_name + ' ' + n1 + ' != ' + n2]
return incorrect


def close_figure(fig=None):
"""Close a matplotlibt figure.

Parameters
----------
fig : int or str or Figure, optional (default=None)
The figure, figure number or figure name to close. If ``None``, all
current figures are closed.
"""
from matplotlib.pyplot import get_fignums, close as _close # noqa

if fig is None:
for fig in get_fignums():
_close(fig)
else:
_close(fig)