Skip to content

Commit

Permalink
Close matplotlib figure windows cleanly so that pytest-xvfb does not …
Browse files Browse the repository at this point in the history
…produce an obscure error at the end of the test.
  • Loading branch information
hodgestar committed Aug 31, 2021
1 parent ac27129 commit d08058b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions qutip/tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,21 @@ 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)
processor = Processor(N=1, spline_kind="cubic")
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)

def testSpline(self):
"""
Expand Down

0 comments on commit d08058b

Please sign in to comment.