Skip to content

Commit

Permalink
Fix MPL warning suppression (#1368)
Browse files Browse the repository at this point in the history
#1362 didn't work as Matplotlib emits warnings through the `logging`
module rather than the `warnings` module. This follows advice
(matplotlib/matplotlib#23326 (comment))
to correctly suppress the warnings.
  • Loading branch information
frankharkins authored May 14, 2024
1 parent 4c743f9 commit 4595971
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/nb-tester/qiskit_docs_notebook_tester/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@

# We always run the following code in the kernel before running the notebook
PRE_EXECUTE_CODE = """\
import warnings
warnings.filterwarnings("ignore", message="Matplotlib is building the font cache; this may take a moment.")
import matplotlib
# See https://github.com/matplotlib/matplotlib/issues/23326#issuecomment-1164772708
matplotlib.set_loglevel("critical")
"""

# If not submitting jobs, we also run this code before notebook execution to mock the real backend
Expand Down

0 comments on commit 4595971

Please sign in to comment.