-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove figure from Gcf when it is closed #1683
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
Changes from 1 commit
121acdc
560f60a
a564b95
b87bffd
3426a78
e56eec2
7a929ca
c613e71
582c72d
def3327
d636acb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
from matplotlib import rcParams | ||
from matplotlib import pyplot as plt | ||
from matplotlib.testing.decorators import cleanup | ||
from matplotlib._pylab_helpers import Gcf | ||
import copy | ||
|
||
|
||
@cleanup | ||
def test_fig_close(): | ||
rcParams['backend'] = 'qt4agg' | ||
# force switch to the Qt4 backend | ||
plt.switch_backend('Qt4Agg') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably mark this test as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the correct way to test if Qt4/PySide is available? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like:
(And obviously extend to also check for PySide -- it should be good enough to have one or the other). |
||
|
||
#save the state of Gcf.figs | ||
init_figs = copy.copy(Gcf.figs) | ||
|
||
# make a figure using pyplot interface | ||
fig = plt.figure() | ||
fig.close() | ||
|
||
# simulate user clicking the close button by reaching in | ||
# and calling close on the underlying Qt object | ||
fig.canvas.manager.window.close() | ||
|
||
# assert that we have removed the reference to the FigureManager | ||
# that got added by plt.figure() | ||
assert(init_figs == Gcf.figs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you moved from
rcParams
toswitch_backend
, so you can remove this line.