Skip to content

Commit

Permalink
Use Agg backend, draw each plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Mar 9, 2018
1 parent d9cf4d5 commit a7a7876
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions properties/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
2. Plotting is stateful, so we have to clean up after each call
With those details taken care of, they all pass!
Note also that a pytest teardown fixture (or unittest method) would not work
here, as they run once per test and we need to clean up once per *example*.
"""
from __future__ import absolute_import, division, print_function

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

from hypothesis import given, settings
Expand Down Expand Up @@ -39,22 +44,26 @@ def test_imshow(arr):
# Note that we clear the plot after each call - otherwise we just get
# errors from polluting state with too many colormaps!
xr.DataArray(arr).plot.imshow()
plt.draw()
plt.clf()


@given(two_dimensional_array)
def test_pcolormesh(arr):
xr.DataArray(arr).plot.pcolormesh()
plt.draw()
plt.clf()


@given(two_dimensional_array)
def test_contour(arr):
xr.DataArray(arr).plot.contour()
plt.draw()
plt.clf()


@given(two_dimensional_array)
def test_contourf(arr):
xr.DataArray(arr).plot.contourf()
plt.draw()
plt.clf()

0 comments on commit a7a7876

Please sign in to comment.