diff --git a/.gitignore b/.gitignore index b8d24ce2e..7c67eba78 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,11 @@ dist/ *.egg* build coverage +.coverage* *.xml .venv .ruff_cache +sg_execution_times.rst # Sphinx documentation doc/_build/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 626784d23..01c291b5a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.4 + rev: v0.4.5 hooks: - id: ruff name: ruff mne_bids/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d716feaf9..bf93a8412 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,7 +53,7 @@ Then, `git clone` your fork and install it in "editable" mode. ```Shell git clone https://github.com//mne-bids cd ./mne-bids -pip install -e .[dev] +pip install -e ".[dev]" git config --local blame.ignoreRevsFile .git-blame-ignore-revs ``` diff --git a/Makefile b/Makefile index b2c475795..8430cc582 100755 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ clean-e: clean: clean-build clean-pyc clean-so clean-ctags clean-cache clean-e inplace: - @python -m pip install -e .[dev] + @python -m pip install -e ".[dev]" test: @echo "Running tests" diff --git a/doc/sphinxext/gen_cli.py b/doc/sphinxext/gen_cli.py index d2a35c8f8..c3bab4c46 100644 --- a/doc/sphinxext/gen_cli.py +++ b/doc/sphinxext/gen_cli.py @@ -8,13 +8,14 @@ # Stefan Appelhoff # # License: BSD-3-Clause -import os import glob -from os import path as op +import os +import shutil import sys +from os import path as op import sphinx.util -from mne.utils import run_subprocess, _replace_md5 +from mne.utils import hashfunc, run_subprocess def setup(app): @@ -116,6 +117,17 @@ def generate_cli_rst(app=None): print("[Done]") +def _replace_md5(fname): + """Replace a file based on MD5sum.""" + # adapted from sphinx-gallery + assert fname.endswith(".new") + fname_old = fname[:-4] + if os.path.isfile(fname_old) and hashfunc(fname) == hashfunc(fname_old): + os.remove(fname) + else: + shutil.move(fname, fname_old) + + # This is useful for testing/iterating to see what the result looks like if __name__ == "__main__": generate_cli_rst() diff --git a/mne_bids/inspect.py b/mne_bids/inspect.py index 45fd33e20..9106cfbe2 100644 --- a/mne_bids/inspect.py +++ b/mne_bids/inspect.py @@ -208,7 +208,7 @@ def _keypress_callback(event): onset=[], duration=[], description=[], orig_time=raw.info["meas_date"] ) - if matplotlib.get_backend() != "agg": + if matplotlib.get_backend().lower() != "agg": plt.show(block=True) _global_vars["raw_fig"] = fig @@ -430,7 +430,7 @@ def _keypress_callback(event): fig.canvas.mpl_connect("close_event", _dont_save_callback) fig.canvas.mpl_connect("key_press_event", _keypress_callback) - if matplotlib.get_backend() != "agg": + if matplotlib.get_backend().lower() != "agg": fig.show() _global_vars["dialog_fig"] = fig diff --git a/mne_bids/tests/test_inspect.py b/mne_bids/tests/test_inspect.py index 2d746aae7..b80a4399a 100644 --- a/mne_bids/tests/test_inspect.py +++ b/mne_bids/tests/test_inspect.py @@ -71,7 +71,7 @@ def test_inspect_single_file(tmp_path, save_changes): import matplotlib.pyplot as plt from mne.utils._testing import _click_ch_name - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -115,7 +115,7 @@ def test_inspect_multiple_files(tmp_path): matplotlib = pytest.importorskip("matplotlib") import matplotlib.pyplot as plt - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -143,7 +143,7 @@ def test_inspect_set_and_unset_bads(tmp_path): import matplotlib.pyplot as plt from mne.utils._testing import _click_ch_name - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -217,7 +217,7 @@ def test_inspect_annotations(tmp_path): matplotlib = pytest.importorskip("matplotlib") import matplotlib.pyplot as plt - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -273,7 +273,7 @@ def test_inspect_annotations_remove_all(tmp_path): matplotlib = pytest.importorskip("matplotlib") import matplotlib.pyplot as plt - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -332,7 +332,7 @@ def test_inspect_dont_show_annotations(tmp_path): matplotlib = pytest.importorskip("matplotlib") import matplotlib.pyplot as plt - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -350,7 +350,7 @@ def test_inspect_bads_and_annotations(tmp_path): import matplotlib.pyplot as plt from mne.utils._testing import _click_ch_name - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path) @@ -391,7 +391,7 @@ def test_inspect_auto_flats(tmp_path, save_changes): matplotlib = pytest.importorskip("matplotlib") import matplotlib.pyplot as plt - matplotlib.use("Agg") + matplotlib.use("agg") plt.close("all") bids_root = setup_bids_test_dir(tmp_path)