Skip to content

Commit 60458bb

Browse files
hawkinspjax authors
authored andcommitted
Fail gracefully in lobpcg_test if matplotlib isn't installed.
There isn't yet a matplotlib that supports NumPy 2.0, so we need to support running tests without it. PiperOrigin-RevId: 621228727
1 parent 00489be commit 60458bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/lobpcg_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ def _debug_plots(self, X, eigs, info, matrix_name, lobpcg_debug_plot_dir):
288288
# We import matplotlib lazily because (a) it's faster this way, and
289289
# (b) concurrent imports of matplotlib appear to trigger some sort of
290290
# collision on the matplotlib cache lock on Windows.
291-
from matplotlib import pyplot as plt
291+
try:
292+
from matplotlib import pyplot as plt
293+
except (ModuleNotFoundError, ImportError):
294+
return # If matplotlib isn't available, don't emit plots.
292295

293296
os.makedirs(lobpcg_debug_plot_dir, exist_ok=True)
294297
clean_matrix_name = _clean_matrix_name(matrix_name)

0 commit comments

Comments
 (0)