Skip to content

Commit 28226fb

Browse files
larsonersnwnde
authored andcommitted
BUG: Fix doc building bugs (mne-tools#12009)
1 parent 764564c commit 28226fb

File tree

10 files changed

+20
-41
lines changed

10 files changed

+20
-41
lines changed

doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
os.environ["MNE_BROWSER_OVERVIEW_MODE"] = "hidden"
3838
os.environ["MNE_BROWSER_THEME"] = "light"
3939
os.environ["MNE_3D_OPTION_THEME"] = "light"
40+
# https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors # noqa: E501
41+
os.environ["NUMBA_CAPTURED_ERRORS"] = "new_style"
4042
sphinx_logger = sphinx.util.logging.getLogger("mne")
4143

4244
# -- Path setup --------------------------------------------------------------

examples/decoding/receptive_field_mtrf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
data = loadmat(join(path, "speech_data.mat"))
5656
raw = data["EEG"].T
5757
speech = data["envelope"].T
58-
sfreq = float(data["Fs"])
58+
sfreq = float(data["Fs"].item())
5959
sfreq /= decim
6060
speech = mne.filter.resample(speech, down=decim, npad="auto")
6161
raw = mne.filter.resample(raw, down=decim, npad="auto")

examples/inverse/mixed_norm_inverse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
)
8888

8989
t = 0.083
90-
tidx = evoked.time_as_index(t)
90+
tidx = evoked.time_as_index(t).item()
9191
for di, dip in enumerate(dipoles, 1):
9292
print(f"Dipole #{di} GOF at {1000 * t:0.1f} ms: " f"{float(dip.gof[tidx]):0.1f}%")
9393

mne/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ def pytest_configure(config):
104104
if os.getenv("PYTEST_QT_API") is None and os.getenv("QT_API") is not None:
105105
os.environ["PYTEST_QT_API"] = os.environ["QT_API"]
106106

107+
# https://numba.readthedocs.io/en/latest/reference/deprecation.html#deprecation-of-old-style-numba-captured-errors # noqa: E501
108+
if "NUMBA_CAPTURED_ERRORS" not in os.environ:
109+
os.environ["NUMBA_CAPTURED_ERRORS"] = "new_style"
110+
107111
# Warnings
108112
# - Once SciPy updates not to have non-integer and non-tuple errors (1.2.0)
109113
# we should remove them from here.

mne/fixes.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,6 @@ def _jit(func):
797797

798798
prange = range
799799
bincount = np.bincount
800-
mean = np.mean
801800

802801
else:
803802

@@ -808,25 +807,6 @@ def bincount(x, weights, minlength): # noqa: D103
808807
out[idx] += w
809808
return out
810809

811-
# fix because Numba does not support axis kwarg for mean
812-
@jit()
813-
def _np_apply_along_axis(func1d, axis, arr):
814-
assert arr.ndim == 2
815-
assert axis in [0, 1]
816-
if axis == 0:
817-
result = np.empty(arr.shape[1])
818-
for i in range(len(result)):
819-
result[i] = func1d(arr[:, i])
820-
else:
821-
result = np.empty(arr.shape[0])
822-
for i in range(len(result)):
823-
result[i] = func1d(arr[i, :])
824-
return result
825-
826-
@jit()
827-
def mean(array, axis): # noqa: D103
828-
return _np_apply_along_axis(np.mean, axis, array)
829-
830810

831811
###############################################################################
832812
# Matplotlib

mne/transforms.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from scipy.spatial.distance import cdist
1616
from scipy.special import sph_harm
1717

18-
from .fixes import jit, mean, _get_img_fdata
18+
from .fixes import jit, _get_img_fdata
1919
from ._fiff.constants import FIFF
2020
from ._fiff.open import fiff_open
2121
from ._fiff.tag import read_tag
@@ -1466,16 +1466,12 @@ def _fit_matched_points(p, x, weights=None, scale=False):
14661466
assert p.ndim == 2
14671467
assert p.shape[1] == 3
14681468
# (weighted) centroids
1469-
if weights is None:
1470-
mu_p = mean(p, axis=0) # eq 23
1471-
mu_x = mean(x, axis=0)
1472-
dots = np.dot(p.T, x)
1473-
dots /= p.shape[0]
1474-
else:
1475-
weights_ = np.reshape(weights / weights.sum(), (weights.size, 1))
1476-
mu_p = np.dot(weights_.T, p)[0]
1477-
mu_x = np.dot(weights_.T, x)[0]
1478-
dots = np.dot(p.T, weights_ * x)
1469+
weights_ = np.full((p.shape[0], 1), 1.0 / max(p.shape[0], 1))
1470+
if weights is not None:
1471+
weights_[:] = np.reshape(weights / weights.sum(), (weights.size, 1))
1472+
mu_p = np.dot(weights_.T, p)[0]
1473+
mu_x = np.dot(weights_.T, x)[0]
1474+
dots = np.dot(p.T, weights_ * x)
14791475
Sigma_px = dots - np.outer(mu_p, mu_x) # eq 24
14801476
# x and p should no longer be used
14811477
A_ij = Sigma_px - Sigma_px.T

mne/viz/_3d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,7 @@ def plot_sparse_source_estimates(
34643464
plt_show(show)
34653465

34663466
renderer.show()
3467+
renderer.set_camera(distance="auto", focalpoint="auto")
34673468
return renderer.scene()
34683469

34693470

tutorials/io/60_ctf_bst_auditory.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
`FieldTrip bug tracker
2222
<http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=2300>`__.
2323
"""
24-
2524
# Authors: Mainak Jas <mainak.jas@telecom-paristech.fr>
2625
# Eric Larson <larson.eric.d@gmail.com>
2726
# Jaakko Leppakangas <jaeilepp@student.jyu.fi>
@@ -39,8 +38,6 @@
3938
from mne.datasets.brainstorm import bst_auditory
4039
from mne.io import read_raw_ctf
4140

42-
print(__doc__)
43-
4441
# %%
4542
# To reduce memory consumption and running time, some of the steps are
4643
# precomputed. To run everything from scratch change ``use_precomputed`` to

tutorials/machine-learning/30_strf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
plt.autoscale(tight=True)
9494
mne.viz.tight_layout()
9595

96-
9796
# %%
9897
# Simulate a neural response
9998
# --------------------------
@@ -186,7 +185,7 @@
186185
rf.fit(X_train, y_train)
187186

188187
# Now make predictions about the model output, given input stimuli.
189-
scores[ii] = rf.score(X_test, y_test)
188+
scores[ii] = rf.score(X_test, y_test).item()
190189
models.append(rf)
191190

192191
times = rf.delays_ / float(rf.sfreq)
@@ -294,7 +293,7 @@
294293
rf.fit(X_train, y_train)
295294

296295
# Now make predictions about the model output, given input stimuli.
297-
scores_lap[ii] = rf.score(X_test, y_test)
296+
scores_lap[ii] = rf.score(X_test, y_test).item()
298297
models_lap.append(rf)
299298

300299
ix_best_alpha_lap = np.argmax(scores_lap)

tutorials/stats-sensor-space/10_background_stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
Here we will briefly cover multiple concepts of inferential statistics in an
99
introductory manner, and demonstrate how to use some MNE statistical functions.
1010
"""
11-
1211
# Authors: Eric Larson <larson.eric.d@gmail.com>
1312
#
1413
# License: BSD-3-Clause
@@ -250,7 +249,8 @@ def plot_t_p(t, p, title, mcc, axes=None):
250249
ps.append(np.zeros(width * width))
251250
mccs.append(False)
252251
for ii in range(n_src):
253-
ts[-1][ii], ps[-1][ii] = permutation_t_test(X[:, [ii]], verbose=False)[:2]
252+
t, p = permutation_t_test(X[:, [ii]], verbose=False)[:2]
253+
ts[-1][ii], ps[-1][ii] = t[0], p[0]
254254
plot_t_p(ts[-1], ps[-1], titles[-1], mccs[-1])
255255

256256
# %%

0 commit comments

Comments
 (0)