Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56d9e7c

Browse filesBrowse files
authored
Merge pull request #19490 from Iain-S/plot-close-error-msg
Fix error message in plt.close().
2 parents 4352733 + 2879446 commit 56d9e7c
Copy full SHA for 56d9e7c

File tree

2 files changed

+9
-1
lines changed
Filter options

2 files changed

+9
-1
lines changed

‎lib/matplotlib/pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/pyplot.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ def close(fig=None):
908908
_pylab_helpers.Gcf.destroy_fig(fig)
909909
else:
910910
raise TypeError("close() argument must be a Figure, an int, a string, "
911-
"or None, not '%s'")
911+
"or None, not %s" % type(fig))
912912

913913

914914
def clf():

‎lib/matplotlib/tests/test_pyplot.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_pyplot.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,11 @@ def test_nested_ion_ioff():
153153
with plt.ioff():
154154
plt.ion()
155155
assert not mpl.is_interactive()
156+
157+
158+
def test_close():
159+
try:
160+
plt.close(1.1)
161+
except TypeError as e:
162+
assert str(e) == "close() argument must be a Figure, an int, " \
163+
"a string, or None, not <class 'float'>"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.