diff --git a/tests/lobpcg_test.py b/tests/lobpcg_test.py index 167e3744b..3a4a2196c 100644 --- a/tests/lobpcg_test.py +++ b/tests/lobpcg_test.py @@ -288,7 +288,10 @@ class LobpcgTest(jtu.JaxTestCase): # We import matplotlib lazily because (a) it's faster this way, and # (b) concurrent imports of matplotlib appear to trigger some sort of # collision on the matplotlib cache lock on Windows. - from matplotlib import pyplot as plt + try: + from matplotlib import pyplot as plt + except (ModuleNotFoundError, ImportError): + return # If matplotlib isn't available, don't emit plots. os.makedirs(lobpcg_debug_plot_dir, exist_ok=True) clean_matrix_name = _clean_matrix_name(matrix_name)