Skip to content

Commit

Permalink
Close matplotlib figure windows cleanly
Browse files Browse the repository at this point in the history
See qutip/qutip#1648

Co-Authored-By: Simon Cross <165551+hodgestar@users.noreply.github.com>
Co-Authored-By: Drew Parsons <26508288+drew-parsons@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 7, 2021
1 parent 4fdc48f commit 0d720c0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ def testPlot(self):
processor.add_control(sigmaz())
processor.pulses[0].tlist = tlist
processor.pulses[0].coeff = np.array([np.sin(t) for t in tlist])
processor.plot_pulses()
plt.clf()
fig, _ = processor.plot_pulses()
# testing under Xvfb with pytest-xvfb complains if figure windows are
# left open, so we politely close it:
plt.close(fig)

# cubic spline
tlist = np.linspace(0., 2*np.pi, 20)
Expand All @@ -180,7 +182,10 @@ def testPlot(self):
processor.pulses[0].tlist = tlist
processor.pulses[0].coeff = np.array([np.sin(t) for t in tlist])
processor.plot_pulses()
plt.clf()
fig, _ = processor.plot_pulses()
# testing under Xvfb with pytest-xvfb complains if figure windows are
# left open, so we politely close it:
plt.close(fig)

def testSpline(self):
"""
Expand Down

0 comments on commit 0d720c0

Please sign in to comment.