Skip to content

Commit

Permalink
MISC maintenance fixes (#1251)
Browse files Browse the repository at this point in the history
* fix pip syntax, add some ignores

* fix syntax for osx in makefile

* bump pre-commit hook

#1256

* fix broken mne import

* need to use .lower() for str comp

* missed one str comp

* Agg -> agg
  • Loading branch information
sappelhoff authored May 28, 2024
1 parent 8e36555 commit a18d070
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ dist/
*.egg*
build
coverage
.coverage*
*.xml
.venv
.ruff_cache
sg_execution_times.rst

# Sphinx documentation
doc/_build/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Then, `git clone` your fork and install it in "editable" mode.
```Shell
git clone https://github.com/<your-GitHub-username>/mne-bids
cd ./mne-bids
pip install -e .[dev]
pip install -e ".[dev]"
git config --local blame.ignoreRevsFile .git-blame-ignore-revs
```

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 15 additions & 3 deletions doc/sphinxext/gen_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
# Stefan Appelhoff <[email protected]>
#
# 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):
Expand Down Expand Up @@ -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()
4 changes: 2 additions & 2 deletions mne_bids/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions mne_bids/tests/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a18d070

Please sign in to comment.