Skip to content

Commit

Permalink
Merge branch 'main' into Replace_percent_format_with_format_specifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya3425-Fst authored Jan 31, 2024
2 parents 51a2741 + 195a2cc commit 663671f
Show file tree
Hide file tree
Showing 50 changed files with 243 additions and 236 deletions.
66 changes: 0 additions & 66 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,6 @@ _check_skip: &check_skip
fi
jobs:
pytest-macos-arm64:
parameters:
scheduled:
type: string
default: "false"
macos:
xcode: "14.2.0"
resource_class: macos.m1.medium.gen1
environment:
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- checkout
- run:
<<: *check_skip
- run:
name: Install Python and dependencies
command: |
set -eo pipefail
brew install [email protected]
which python
which pip
pip install --upgrade pip
pip install --upgrade --only-binary "numpy,scipy,dipy,statsmodels" -ve .[full,test_extra]
# 3D too slow on Apple's software renderer, and numba causes us problems
pip uninstall -y vtk pyvista pyvistaqt numba
mkdir -p test-results
echo "set -eo pipefail" >> $BASH_ENV
- run:
command: mne sys_info
- run:
command: ./tools/get_testing_version.sh && cat testing_version.txt
- restore_cache:
keys:
- data-cache-testing-{{ checksum "testing_version.txt" }}
- run:
command: python -c "import mne; mne.datasets.testing.data_path(verbose=True)"
- save_cache:
key: data-cache-testing-{{ checksum "testing_version.txt" }}
paths:
- ~/mne_data/MNE-testing-data # (2.5 G)
- run:
command: pytest -m "not slowtest" --tb=short --cov=mne --cov-report xml -vv mne
- run:
name: Prepare test data upload
command: cp -av junit-results.xml test-results/junit.xml
- store_test_results:
path: ./test-results
# Codecov orb has bugs on macOS (gpg issues)
# - codecov/upload
- run:
command: bash <(curl -s https://codecov.io/bash)

build_docs:
parameters:
scheduled:
Expand Down Expand Up @@ -591,20 +539,6 @@ workflows:
only:
- main

weekly:
jobs:
- pytest-macos-arm64:
name: pytest_macos_arm64_weekly
scheduled: "true"
triggers:
- schedule:
# "At 6:00 AM GMT every Monday"
cron: "0 6 * * 1"
filters:
branches:
only:
- main

monthly:
jobs:
- linkcheck:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ jobs:
- os: ubuntu-latest
python: '3.12'
kind: conda
- os: macos-latest
# 3.12 needs https://github.com/conda-forge/dipy-feedstock/pull/50
- os: macos-14 # arm64
python: '3.11'
kind: mamba
- os: macos-latest # intel
python: '3.11'
kind: mamba
- os: windows-latest
Expand Down Expand Up @@ -104,6 +108,9 @@ jobs:
mamba
fmt!=10.2.0
if: ${{ !startswith(matrix.kind, 'pip') }}
# Make sure we have the right Python
- run: python -c "import platform; assert platform.machine() == 'arm64', platform.machine()"
if: matrix.os == 'macos-14'
- run: ./tools/github_actions_dependencies.sh
# Minimal commands on Linux (macOS stalls)
- run: ./tools/get_minimal_commands.sh
Expand Down
2 changes: 1 addition & 1 deletion doc/changes/devel/12326.other.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Updated the text in the preprocessing tutorial to use :class:`mne.io.Raw.pick()` instead of the legacy :class:`mne.io.Raw.pick_types()`, by :newcontrib:`btkcodedev`.
Updated the text in the preprocessing tutorial to use :meth:`mne.io.Raw.pick` instead of the legacy :meth:`mne.io.Raw.pick_types`, by :newcontrib:`btkcodedev`.
1 change: 1 addition & 0 deletions doc/changes/devel/12376.dependency.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For developers, ``pytest>=8.0`` is now required for running unit tests, by `Eric Larson`_.
1 change: 1 addition & 0 deletions doc/changes/devel/12399.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bugs with :class:`mne.Report` CSS where TOC items could disappear at the bottom of the page, by `Eric Larson`_.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- pip
- numpy
- scipy
- openblas!=0.3.26 # until https://github.com/conda-forge/scipy-feedstock/pull/268 lands
- openblas
- matplotlib
- tqdm
- pooch>=1.5
Expand Down
7 changes: 4 additions & 3 deletions mne/_fiff/tests/test_meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ def test_read_write_info(tmp_path):
@testing.requires_testing_data
def test_dir_warning():
"""Test that trying to read a bad filename emits a warning before an error."""
with pytest.raises(OSError, match="directory"):
with pytest.warns(RuntimeWarning, match="foo"):
read_info(ctf_fname)
with pytest.raises(OSError, match="directory"), pytest.warns(
RuntimeWarning, match="does not conform"
):
read_info(ctf_fname)


def test_io_dig_points(tmp_path):
Expand Down
27 changes: 14 additions & 13 deletions mne/beamformer/tests/test_lcmv.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,19 +589,20 @@ def test_make_lcmv_sphere(pick_ori, weight_norm):
fwd_sphere = mne.make_forward_solution(evoked.info, None, src, sphere)

# Test that we get an error if not reducing rank
with pytest.raises(ValueError, match="Singular matrix detected"):
with pytest.warns(RuntimeWarning, match="positive semidefinite"):
make_lcmv(
evoked.info,
fwd_sphere,
data_cov,
reg=0.1,
noise_cov=noise_cov,
weight_norm=weight_norm,
pick_ori=pick_ori,
reduce_rank=False,
rank="full",
)
with pytest.raises(
ValueError, match="Singular matrix detected"
), _record_warnings(), pytest.warns(RuntimeWarning, match="positive semidefinite"):
make_lcmv(
evoked.info,
fwd_sphere,
data_cov,
reg=0.1,
noise_cov=noise_cov,
weight_norm=weight_norm,
pick_ori=pick_ori,
reduce_rank=False,
rank="full",
)

# Now let's reduce it
filters = make_lcmv(
Expand Down
5 changes: 4 additions & 1 deletion mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
_assert_no_instances,
_check_qt_version,
_pl,
_record_warnings,
_TempDir,
numerics,
)
Expand Down Expand Up @@ -801,7 +802,9 @@ def src_volume_labels():
"""Create a 7mm source space with labels."""
pytest.importorskip("nibabel")
volume_labels = mne.get_volume_labels_from_aseg(fname_aseg)
with pytest.warns(RuntimeWarning, match="Found no usable.*t-vessel.*"):
with _record_warnings(), pytest.warns(
RuntimeWarning, match="Found no usable.*t-vessel.*"
):
src = mne.setup_volume_source_space(
"sample",
7.0,
Expand Down
8 changes: 6 additions & 2 deletions mne/export/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def test_export_raw_pybv(tmp_path, meas_date, orig_time, ext):
raw.set_annotations(annots)

temp_fname = tmp_path / ("test" + ext)
with pytest.warns(RuntimeWarning, match="'short' format. Converting"):
with _record_warnings(), pytest.warns(
RuntimeWarning, match="'short' format. Converting"
):
raw.export(temp_fname)
raw_read = read_raw_brainvision(str(temp_fname).replace(".eeg", ".vhdr"))
assert raw.ch_names == raw_read.ch_names
Expand Down Expand Up @@ -301,7 +303,9 @@ def test_export_edf_signal_clipping(tmp_path, physical_range, exceeded_bound):
raw = read_raw_fif(fname_raw)
raw.pick(picks=["eeg", "ecog", "seeg"]).load_data()
temp_fname = tmp_path / "test.edf"
with pytest.warns(RuntimeWarning, match=f"The {exceeded_bound}"):
with _record_warnings(), pytest.warns(
RuntimeWarning, match=f"The {exceeded_bound}"
):
raw.export(temp_fname, physical_range=physical_range)
raw_read = read_raw_edf(temp_fname, preload=True)
assert raw_read.get_data().min() >= physical_range[0]
Expand Down
11 changes: 7 additions & 4 deletions mne/forward/tests/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
from mne.io import read_info
from mne.label import read_label
from mne.utils import requires_mne, run_subprocess
from mne.utils import _record_warnings, requires_mne, run_subprocess

data_path = testing.data_path(download=False)
fname_meeg = data_path / "MEG" / "sample" / "sample_audvis_trunc-meg-eeg-oct-4-fwd.fif"
Expand Down Expand Up @@ -230,7 +230,9 @@ def test_apply_forward():
# Evoked
evoked = read_evokeds(fname_evoked, condition=0)
evoked.pick(picks="meg")
with pytest.warns(RuntimeWarning, match="only .* positive values"):
with _record_warnings(), pytest.warns(
RuntimeWarning, match="only .* positive values"
):
evoked = apply_forward(fwd, stc, evoked.info, start=start, stop=stop)
data = evoked.data
times = evoked.times
Expand All @@ -248,13 +250,14 @@ def test_apply_forward():
stc.tmin,
stc.tstep,
)
with pytest.warns(RuntimeWarning, match="very large"):
large_ctx = pytest.warns(RuntimeWarning, match="very large")
with large_ctx:
evoked_2 = apply_forward(fwd, stc_vec, evoked.info)
assert np.abs(evoked_2.data).mean() > 1e-5
assert_allclose(evoked.data, evoked_2.data, atol=1e-10)

# Raw
with pytest.warns(RuntimeWarning, match="only .* positive values"):
with large_ctx, pytest.warns(RuntimeWarning, match="only .* positive values"):
raw_proj = apply_forward_raw(fwd, stc, evoked.info, start=start, stop=stop)
data, times = raw_proj[:, :]

Expand Down
3 changes: 2 additions & 1 deletion mne/forward/tests/test_make_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from mne.surface import _get_ico_surface
from mne.transforms import Transform
from mne.utils import (
_record_warnings,
catch_logging,
requires_mne,
requires_mne_mark,
Expand Down Expand Up @@ -198,7 +199,7 @@ def test_magnetic_dipole():
r0 = coils[0]["rmag"][[0]]
with pytest.raises(RuntimeError, match="Coil too close"):
_magnetic_dipole_field_vec(r0, coils[:1])
with pytest.warns(RuntimeWarning, match="Coil too close"):
with _record_warnings(), pytest.warns(RuntimeWarning, match="Coil too close"):
fwd = _magnetic_dipole_field_vec(r0, coils[:1], too_close="warning")
assert not np.isfinite(fwd).any()
with np.errstate(invalid="ignore"):
Expand Down
5 changes: 0 additions & 5 deletions mne/html/d3.v3.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions mne/html/mpld3.v0.2.min.js

This file was deleted.

4 changes: 3 additions & 1 deletion mne/io/artemis123/tests/test_artemis123.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def test_dev_head_t():
assert_equal(raw.info["sfreq"], 5000.0)

# test with head loc and digitization
with pytest.warns(RuntimeWarning, match="Large difference"):
with pytest.warns(RuntimeWarning, match="consistency"), pytest.warns(
RuntimeWarning, match="Large difference"
):
raw = read_raw_artemis123(
short_HPI_dip_fname, add_head_trans=True, pos_fname=dig_fname
)
Expand Down
14 changes: 8 additions & 6 deletions mne/io/brainvision/brainvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ def _read_annotations_brainvision(fname, sfreq="auto"):

def _check_bv_version(header, kind):
"""Check the header version."""
_data_err = """\
MNE-Python currently only supports %s versions 1.0 and 2.0, got unparsable\
%r. Contact MNE-Python developers for support."""
_data_err = (
"MNE-Python currently only supports %s versions 1.0 and 2.0, got unparsable "
"%r. Contact MNE-Python developers for support."
)
# optional space, optional Core or V-Amp, optional Exchange,
# Version/Header, optional comma, 1/2
_data_re = (
Expand All @@ -355,14 +356,15 @@ def _check_bv_version(header, kind):

assert kind in ("header", "marker")

if header == "":
warn(f"Missing header in {kind} file.")
for version in range(1, 3):
this_re = _data_re % (kind.capitalize(), version)
if re.search(this_re, header) is not None:
return version
else:
warn(_data_err % (kind, header))
if header == "":
warn(f"Missing header in {kind} file.")
else:
warn(_data_err % (kind, header))


_orientation_dict = dict(MULTIPLEXED="F", VECTORIZED="C")
Expand Down
14 changes: 9 additions & 5 deletions mne/io/brainvision/tests/test_brainvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mne.datasets import testing
from mne.io import read_raw_brainvision, read_raw_fif
from mne.io.tests.test_raw import _test_raw_reader
from mne.utils import _stamp_to_dt, object_diff
from mne.utils import _record_warnings, _stamp_to_dt, object_diff

data_dir = Path(__file__).parent / "data"
vhdr_path = data_dir / "test.vhdr"
Expand Down Expand Up @@ -72,6 +72,8 @@
# This should be amend in its own PR.
montage = data_dir / "test.hpts"

_no_dig = pytest.warns(RuntimeWarning, match="No info on DataPoints")


def test_orig_units(recwarn):
"""Test exposure of original channel units."""
Expand Down Expand Up @@ -473,7 +475,7 @@ def test_brainvision_data_partially_disabled_hw_filters():

def test_brainvision_data_software_filters_latin1_global_units():
"""Test reading raw Brain Vision files."""
with pytest.warns(RuntimeWarning, match="software filter"):
with _no_dig, pytest.warns(RuntimeWarning, match="software filter"):
raw = _test_raw_reader(
read_raw_brainvision,
vhdr_fname=vhdr_old_path,
Expand All @@ -485,7 +487,7 @@ def test_brainvision_data_software_filters_latin1_global_units():
assert raw.info["lowpass"] == 50.0

# test sensor name with spaces (#9299)
with pytest.warns(RuntimeWarning, match="software filter"):
with _no_dig, pytest.warns(RuntimeWarning, match="software filter"):
raw = _test_raw_reader(
read_raw_brainvision,
vhdr_fname=vhdr_old_longname_path,
Expand Down Expand Up @@ -566,7 +568,7 @@ def test_brainvision_data():

def test_brainvision_vectorized_data():
"""Test reading BrainVision data files with vectorized data."""
with pytest.warns(RuntimeWarning, match="software filter"):
with _no_dig, pytest.warns(RuntimeWarning, match="software filter"):
raw = read_raw_brainvision(vhdr_old_path, preload=True)

assert_array_equal(raw._data.shape, (29, 251))
Expand Down Expand Up @@ -611,7 +613,9 @@ def test_brainvision_vectorized_data():
def test_coodinates_extraction():
"""Test reading of [Coordinates] section if present."""
# vhdr 2 has a Coordinates section
with pytest.warns(RuntimeWarning, match="coordinate information"):
with _record_warnings(), pytest.warns(
RuntimeWarning, match="coordinate information"
):
raw = read_raw_brainvision(vhdr_v2_path)

# Basic check of extracted coordinates
Expand Down
Loading

0 comments on commit 663671f

Please sign in to comment.