Skip to content
Snippets Groups Projects
Commit bda8f015 authored by Joseph Weston's avatar Joseph Weston
Browse files

use matplotlib's 'Agg' backend in tests if not already selected

This backend does not require a display to be connected,
which is good for tests.

Closes #83.
parent 290fcbf2
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -15,14 +15,26 @@ from math import cos, sin
import scipy.integrate
import scipy.stats
import pytest
import sys
import kwant
from kwant import plotter
from kwant._common import ensure_rng
if plotter.mpl_enabled:
try:
from mpl_toolkits import mplot3d
import matplotlib
# If the user did not already choose a backend, then choose
# the one with the least dependencies.
# This check is the same as the one performed inside matplotlib.use.
if 'matplotlib.backends' not in sys.modules:
matplotlib.use('Agg')
from matplotlib import pyplot # pragma: no flakes
except ImportError:
pass
from kwant import plotter
def test_importable_without_matplotlib():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment