Skip to content

Commit

Permalink
MAINT: Work around NumPy deprecation (#11878)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Aug 14, 2023
1 parent 2188c25 commit 522cf44
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,10 @@ def reset_warnings(gallery_conf, fname):
"ignore",
message="Matplotlib is currently using agg, which is a non-GUI backend.*",
)
warnings.filterwarnings(
"ignore",
message=".*is non-interactive, and thus cannot.*",
)
# seaborn
warnings.filterwarnings(
"ignore",
Expand Down
8 changes: 6 additions & 2 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ def pytest_configure(config):
ignore:unclosed event loop <:ResourceWarning
# ignore if joblib is missing
ignore:joblib not installed.*:RuntimeWarning
# TODO: This is indicative of a problem
ignore:.*Matplotlib is currently using agg.*:
# qdarkstyle
ignore:.*Setting theme=.*:RuntimeWarning
# scikit-learn using this arg
Expand Down Expand Up @@ -158,6 +156,12 @@ def pytest_configure(config):
ignore:.*np\.find_common_type is deprecated.*:DeprecationWarning
# https://github.com/joblib/joblib/issues/1454
ignore:.*`byte_bounds` is dep.*:DeprecationWarning
# numpy distutils used by SciPy
ignore:(\n|.)*numpy\.distutils` is deprecated since NumPy(\n|.)*:DeprecationWarning
ignore:datetime\.utcfromtimestamp.*is deprecated:DeprecationWarning
ignore:The numpy\.array_api submodule is still experimental.*:UserWarning
# tqdm (Fedora)
ignore:.*'tqdm_asyncio' object has no attribute 'last_print_t':pytest.PytestUnraisableExceptionWarning
""" # noqa: E501
for warning_line in warning_lines.split("\n"):
warning_line = warning_line.strip()
Expand Down
3 changes: 3 additions & 0 deletions mne/viz/_mpl_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
# https://github.com/matplotlib/matplotlib/issues/23298
# but wrapping it in ion() context makes it go away.
# Moving this bit to a separate function in ../../fixes.py doesn't work.
#
# TODO: Once we require matplotlib 3.6 we should be able to remove this.
# It also causes some problems... see mne/viz/utils.py:plt_show() for details.

# CONSTANTS (inches)
ANNOTATION_FIG_PAD = 0.1
Expand Down
4 changes: 2 additions & 2 deletions mne/viz/topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def _imshow_tfr_unified(
ax.imshow(
tfr[ch_idx],
clip_on=True,
clip_box=bn.pos,
clip_box=tuple(bn.pos),
extent=extent,
aspect="auto",
origin="lower",
Expand Down Expand Up @@ -672,7 +672,7 @@ def _plot_timeseries_unified(
linewidth=0.5,
color=color_,
clip_on=True,
clip_box=pos,
clip_box=tuple(pos),
)[0]
)
if vline:
Expand Down
10 changes: 10 additions & 0 deletions mne/viz/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,19 @@ def plt_show(show=True, fig=None, **kwargs):

if hasattr(fig, "mne") and hasattr(fig.mne, "backend"):
backend = fig.mne.backend
# TODO: This is a hack to deal with the fact that the
# with plt.ion():
# BACKEND = get_backend()
# an the top of _mpl_figure detects QtAgg during testing even though
# we've set the backend to Agg.
if backend != "agg":
gotten_backend = get_backend()
if gotten_backend == "agg":
backend = "agg"
else:
backend = get_backend()
if show and backend != "agg":
logger.debug(f"Showing plot for backend {repr(backend)}")
(fig or plt).show(**kwargs)


Expand Down

0 comments on commit 522cf44

Please sign in to comment.