Skip to content

Commit 1fe211a

Browse files
authored
BUG: Fix bug with parallel doc build (#13140)
1 parent 266ccc9 commit 1fe211a

File tree

5 files changed

+43
-110
lines changed

5 files changed

+43
-110
lines changed

doc/sphinxext/mne_doc_utils.py

Lines changed: 27 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -51,125 +51,46 @@ def reset_warnings(gallery_conf, fname):
5151
)
5252
# internal warnings
5353
warnings.filterwarnings("default", module="sphinx")
54-
# allow these warnings, but don't show them
54+
# don't error on joblib warning during parallel doc build otherwise we get a
55+
# cryptic deadlock instead of a nice traceback
56+
warnings.filterwarnings(
57+
"always",
58+
"A worker stopped while some jobs were given to the executor.*",
59+
category=UserWarning,
60+
)
61+
# ignore (DeprecationWarning)
5562
for key in (
56-
"invalid version and will not be supported", # pyxdf
57-
"distutils Version classes are deprecated", # seaborn and neo
58-
"is_categorical_dtype is deprecated", # seaborn
59-
"`np.object` is a deprecated alias for the builtin `object`", # pyxdf
60-
# nilearn, should be fixed in > 0.9.1
61-
"In future, it will be an error for 'np.bool_' scalars to",
62-
# sklearn hasn't updated to SciPy's sym_pos dep
63-
"The 'sym_pos' keyword is deprecated",
64-
# numba
65-
"`np.MachAr` is deprecated",
66-
# joblib hasn't updated to avoid distutils
67-
"distutils package is deprecated",
68-
# jupyter
69-
"Jupyter is migrating its paths to use standard",
70-
r"Widget\..* is deprecated\.",
71-
# PyQt6
72-
"Enum value .* is marked as deprecated",
73-
# matplotlib PDF output
74-
"The py23 module has been deprecated",
75-
# pkg_resources
76-
"Implementing implicit namespace packages",
77-
"Deprecated call to `pkg_resources",
78-
# nilearn
79-
"pkg_resources is deprecated as an API",
80-
r"The .* was deprecated in Matplotlib 3\.7",
81-
# Matplotlib->tz
82-
r"datetime\.datetime\.utcfromtimestamp",
83-
# joblib
84-
r"ast\.Num is deprecated",
85-
r"Attribute n is deprecated and will be removed in Python 3\.14",
86-
# numpydoc
87-
r"ast\.NameConstant is deprecated and will be removed in Python 3\.14",
88-
# pooch
89-
r"Python 3\.14 will, by default, filter extracted tar archives.*",
90-
# seaborn
91-
r"DataFrameGroupBy\.apply operated on the grouping columns.*",
92-
# pandas
93-
r"\nPyarrow will become a required dependency of pandas.*",
94-
# latexcodec
95-
r"open_text is deprecated\. Use files.*",
96-
# python-quantities, via neo
97-
r"numpy\.core is deprecated and has been renamed to numpy\._core",
98-
# matplotlib
99-
"__array_wrap__ must accept context and return_scalar.*",
10063
# nibabel
10164
"__array__ implementation doesn't accept.*",
65+
# pybtex (from sphinxcontrib-bibtex)
66+
"pkg_resources is deprecated as an API.*",
67+
"\nImplementing implicit namespace packages",
68+
# latexcodec
69+
r"open_text is deprecated\. Use files",
10270
):
10371
warnings.filterwarnings( # deal with other modules having bad imports
10472
"ignore", message=f".*{key}.*", category=DeprecationWarning
10573
)
106-
warnings.filterwarnings(
107-
"ignore",
108-
message="Matplotlib is currently using agg, which is a non-GUI backend.*",
109-
)
110-
warnings.filterwarnings(
111-
"ignore",
112-
message=".*is non-interactive, and thus cannot.*",
113-
)
114-
# seaborn
115-
warnings.filterwarnings(
116-
"ignore",
117-
message="The figure layout has changed to tight",
118-
category=UserWarning,
119-
)
120-
# xarray/netcdf4
121-
warnings.filterwarnings(
122-
"ignore",
123-
message=r"numpy\.ndarray size changed, may indicate.*",
124-
category=RuntimeWarning,
125-
)
126-
# qdarkstyle
127-
warnings.filterwarnings(
128-
"ignore",
129-
message=r".*Setting theme=.*6 in qdarkstyle.*",
130-
category=RuntimeWarning,
131-
)
132-
# pandas, via seaborn (examples/time_frequency/time_frequency_erds.py)
74+
# ignore (UserWarning)
13375
for message in (
134-
"use_inf_as_na option is deprecated.*",
135-
r"iteritems is deprecated.*Use \.items instead\.",
136-
"is_categorical_dtype is deprecated.*",
137-
"The default of observed=False.*",
138-
"When grouping with a length-1 list-like.*",
76+
# Matplotlib
77+
".*is non-interactive, and thus cannot.*",
13978
):
14079
warnings.filterwarnings(
14180
"ignore",
14281
message=message,
143-
category=FutureWarning,
82+
category=UserWarning,
83+
)
84+
# ignore (RuntimeWarning)
85+
for message in (
86+
# mne-python config file "corruption" due to doc build parallelization
87+
".*The MNE-Python config file.*valid JSON.*",
88+
):
89+
warnings.filterwarnings(
90+
"ignore",
91+
message=message,
92+
category=RuntimeWarning,
14493
)
145-
# pandas in 50_epochs_to_data_frame.py
146-
warnings.filterwarnings(
147-
"ignore", message=r"invalid value encountered in cast", category=RuntimeWarning
148-
)
149-
# xarray _SixMetaPathImporter (?)
150-
warnings.filterwarnings(
151-
"ignore", message=r"falling back to find_module", category=ImportWarning
152-
)
153-
# Sphinx deps
154-
warnings.filterwarnings(
155-
"ignore", message="The str interface for _CascadingStyleSheet.*"
156-
)
157-
# mne-qt-browser until > 0.5.2 released
158-
warnings.filterwarnings(
159-
"ignore",
160-
r"mne\.io\.pick.channel_indices_by_type is deprecated.*",
161-
)
162-
# parallel building
163-
warnings.filterwarnings(
164-
"ignore",
165-
"A worker stopped while some jobs were given to the executor.*",
166-
category=UserWarning,
167-
)
168-
# neo
169-
warnings.filterwarnings(
170-
"ignore",
171-
"The 'copy' argument in Quantity is deprecated.*",
172-
)
17394

17495
# In case we use np.set_printoptions in any tutorials, we only
17596
# want it to affect those:

mne/event.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ def find_events(
767767
picks = pick_channels(raw.info["ch_names"], include=stim_channel)
768768
if len(picks) == 0:
769769
raise ValueError("No stim channel found to extract event triggers.")
770+
logger.info(f"Finding events on: {', '.join(raw.ch_names[pick] for pick in picks)}")
770771
data, _ = raw[picks, :]
771772

772773
events_list = []

mne/io/eyelink/_utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ def _set_missing_values(df, columns):
440440
missing_vals = (".", "MISSING_DATA")
441441
for col in columns:
442442
# we explicitly use numpy instead of pd.replace because it is faster
443-
df[col] = np.where(df[col].isin(missing_vals), np.nan, df[col])
443+
# if a stim channel (DIN) we should use zero so it can cast to int properly
444+
# in find_events
445+
replacement = 0 if col == "DIN" else np.nan
446+
df[col] = np.where(df[col].isin(missing_vals), replacement, df[col])
444447

445448

446449
def _sort_by_time(df, col="time"):
@@ -517,9 +520,13 @@ def _adjust_times(
517520
new_times = pd.DataFrame(
518521
np.arange(first, last + step / 2, step), columns=[time_col]
519522
)
520-
return pd.merge_asof(
523+
df = pd.merge_asof(
521524
new_times, df, on=time_col, direction="nearest", tolerance=step / 2
522525
)
526+
# fix DIN NaN values
527+
if "DIN" in df.columns:
528+
df["DIN"] = df["DIN"].fillna(0)
529+
return df
523530

524531

525532
def _find_overlaps(df, max_time=0.05):

mne/io/eyelink/tests/test_eyelink.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99
from numpy.testing import assert_allclose
1010

11+
from mne import find_events
1112
from mne._fiff.constants import FIFF
1213
from mne._fiff.pick import _DATA_CH_TYPES_SPLIT
1314
from mne.datasets.testing import data_path, requires_testing_data
@@ -285,6 +286,9 @@ def test_multi_block_misc_channels(fname, tmp_path):
285286
assert not np.isnan(data[0, np.where(times < 1)[0]]).any()
286287
assert np.isnan(data[0, np.logical_and(times > 1, times <= 1.1)]).all()
287288

289+
# smoke test for reading events with missing samples (should not emit a warning)
290+
find_events(raw, verbose=True)
291+
288292

289293
@requires_testing_data
290294
@pytest.mark.parametrize("this_fname", (fname, fname_href))

tutorials/preprocessing/90_eyetracking_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
a pupillary light reflex task. We will combine the eye-tracking and EEG data, and plot
1010
the ERP and pupil response to the light flashes (i.e. the pupillary light reflex).
1111
12-
""" # noqa: E501
12+
"""
13+
1314
# Authors: Scott Huberty <seh33@uw.edu>
1415
# Dominik Welke <dominik.welke@web.de>
1516
#
16-
#
1717
# License: BSD-3-Clause
1818
# Copyright the MNE-Python contributors.
1919

0 commit comments

Comments
 (0)