From d6d01a1af45cd6266efa5d029b536c32912450f6 Mon Sep 17 00:00:00 2001 From: Adam Li Date: Fri, 2 Feb 2024 11:27:50 -0500 Subject: [PATCH 1/9] Fix ci Signed-off-by: Adam Li --- mne_icalabel/gui/_label_components.pyi | 12 ------------ mne_icalabel/iclabel/tests/test_label_components.py | 9 ++++++--- mne_icalabel/utils/_docs.py | 8 ++++++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/mne_icalabel/gui/_label_components.pyi b/mne_icalabel/gui/_label_components.pyi index 1a906d7a8..8cb7a7d3d 100644 --- a/mne_icalabel/gui/_label_components.pyi +++ b/mne_icalabel/gui/_label_components.pyi @@ -54,46 +54,34 @@ class ICAComponentLabeler(QMainWindow): - topomap - psd """ - @staticmethod def _check_inst_ica(inst: Union[BaseRaw, BaseEpochs], ica: ICA) -> None: """Check if the ICA was fitted.""" - @property def inst(self) -> Union[BaseRaw, BaseEpochs]: """Instance on which the ICA has been fitted.""" - @property def ica(self) -> ICA: """Fitted ICA decomposition.""" - @property def n_components_(self) -> int: """The number of fitted components.""" - @property def labels(self) -> list[str]: """List of valid labels.""" - @property def selected_component(self) -> int: """IC selected and displayed.""" - def _connect_signals_to_slots(self) -> None: """Connect all the signals and slots of the GUI.""" - def _components_listWidget_clicked(self) -> None: """Update the plots and the saved labels accordingly.""" - def _update_selected_labels(self) -> None: """Update the labels saved.""" - def _reset(self) -> None: """Action of the reset button.""" - def _reset_buttons(self) -> None: """Reset all buttons.""" - def closeEvent(self, event) -> None: """Clean up upon closing the window. diff --git a/mne_icalabel/iclabel/tests/test_label_components.py b/mne_icalabel/iclabel/tests/test_label_components.py index d804af84a..291897c20 100644 --- a/mne_icalabel/iclabel/tests/test_label_components.py +++ b/mne_icalabel/iclabel/tests/test_label_components.py @@ -124,13 +124,16 @@ def test_warnings(): random_state=101, ) ica.fit(raw) - with pytest.warns(RuntimeWarning, match="common average reference"): - iclabel_label_components(raw, ica) with pytest.warns(RuntimeWarning, match="not filtered between 1 and 100 Hz"): iclabel_label_components(raw, ica) - with raw.info._unlock(): raw.info["lowpass"] = 100.0 + + with pytest.warns(RuntimeWarning, match="common average reference"): + raw_copy = raw.copy() + with raw_copy.info._unlock(): + raw_copy.info["custom_ref_applied"] = 0 + iclabel_label_components(raw_copy, ica) raw.set_eeg_reference("average") # infomax ica = ICA( diff --git a/mne_icalabel/utils/_docs.py b/mne_icalabel/utils/_docs.py index b0c3a9cfc..73200eee0 100644 --- a/mne_icalabel/utils/_docs.py +++ b/mne_icalabel/utils/_docs.py @@ -43,7 +43,9 @@ # -- G --------------------------------------------------------------------------------- # -- H --------------------------------------------------------------------------------- # -- I --------------------------------------------------------------------------------- -docdict["image_interp_topomap"] = """ +docdict[ + "image_interp_topomap" +] = """ image_interp : str The image interpolation to be used. All matplotlib options are accepted.""" @@ -57,7 +59,9 @@ # -- P --------------------------------------------------------------------------------- # -- Q --------------------------------------------------------------------------------- # -- R --------------------------------------------------------------------------------- -docdict["res_topomap"] = """ +docdict[ + "res_topomap" +] = """ res : int The resolution of the square topographic map (in pixels).""" From e7580bdd36c1d0f1a1055b1403c903697da23cef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 16:28:19 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne_icalabel/utils/_docs.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mne_icalabel/utils/_docs.py b/mne_icalabel/utils/_docs.py index 73200eee0..b0c3a9cfc 100644 --- a/mne_icalabel/utils/_docs.py +++ b/mne_icalabel/utils/_docs.py @@ -43,9 +43,7 @@ # -- G --------------------------------------------------------------------------------- # -- H --------------------------------------------------------------------------------- # -- I --------------------------------------------------------------------------------- -docdict[ - "image_interp_topomap" -] = """ +docdict["image_interp_topomap"] = """ image_interp : str The image interpolation to be used. All matplotlib options are accepted.""" @@ -59,9 +57,7 @@ # -- P --------------------------------------------------------------------------------- # -- Q --------------------------------------------------------------------------------- # -- R --------------------------------------------------------------------------------- -docdict[ - "res_topomap" -] = """ +docdict["res_topomap"] = """ res : int The resolution of the square topographic map (in pixels).""" From 7b760a926178d46da894857a780b65830ef86fc2 Mon Sep 17 00:00:00 2001 From: Adam Li Date: Fri, 2 Feb 2024 11:30:13 -0500 Subject: [PATCH 3/9] Fix pre-commit Signed-off-by: Adam Li --- mne_icalabel/utils/_docs.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mne_icalabel/utils/_docs.py b/mne_icalabel/utils/_docs.py index 73200eee0..b0c3a9cfc 100644 --- a/mne_icalabel/utils/_docs.py +++ b/mne_icalabel/utils/_docs.py @@ -43,9 +43,7 @@ # -- G --------------------------------------------------------------------------------- # -- H --------------------------------------------------------------------------------- # -- I --------------------------------------------------------------------------------- -docdict[ - "image_interp_topomap" -] = """ +docdict["image_interp_topomap"] = """ image_interp : str The image interpolation to be used. All matplotlib options are accepted.""" @@ -59,9 +57,7 @@ # -- P --------------------------------------------------------------------------------- # -- Q --------------------------------------------------------------------------------- # -- R --------------------------------------------------------------------------------- -docdict[ - "res_topomap" -] = """ +docdict["res_topomap"] = """ res : int The resolution of the square topographic map (in pixels).""" From 3bfa739eb289509e39621b07e40dadfbeaf58605 Mon Sep 17 00:00:00 2001 From: Adam Li Date: Fri, 2 Feb 2024 12:24:19 -0500 Subject: [PATCH 4/9] Fix unit-tests Signed-off-by: Adam Li --- mne_icalabel/iclabel/tests/test_label_components.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mne_icalabel/iclabel/tests/test_label_components.py b/mne_icalabel/iclabel/tests/test_label_components.py index 291897c20..56ac66c76 100644 --- a/mne_icalabel/iclabel/tests/test_label_components.py +++ b/mne_icalabel/iclabel/tests/test_label_components.py @@ -124,17 +124,18 @@ def test_warnings(): random_state=101, ) ica.fit(raw) - with pytest.warns(RuntimeWarning, match="not filtered between 1 and 100 Hz"): - iclabel_label_components(raw, ica) - with raw.info._unlock(): - raw.info["lowpass"] = 100.0 - with pytest.warns(RuntimeWarning, match="common average reference"): raw_copy = raw.copy() with raw_copy.info._unlock(): raw_copy.info["custom_ref_applied"] = 0 iclabel_label_components(raw_copy, ica) raw.set_eeg_reference("average") + + with pytest.warns(RuntimeWarning, match="not filtered between 1 and 100 Hz"): + iclabel_label_components(raw, ica) + with raw.info._unlock(): + raw.info["lowpass"] = 100.0 + # infomax ica = ICA( n_components=3, From d348c6e3c0b7129d27eb0670eb9a5e8a2bc1f7d4 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Mon, 5 Feb 2024 15:39:56 +0100 Subject: [PATCH 5/9] improve style and run stubgen --- mne_icalabel/datasets/icalabel/icalabel.py | 2 +- mne_icalabel/datasets/icalabel/icalabel.pyi | 2 +- mne_icalabel/gui/_label_components.pyi | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mne_icalabel/datasets/icalabel/icalabel.py b/mne_icalabel/datasets/icalabel/icalabel.py index 155dce703..96ad626a0 100644 --- a/mne_icalabel/datasets/icalabel/icalabel.py +++ b/mne_icalabel/datasets/icalabel/icalabel.py @@ -42,7 +42,7 @@ def data_path( download : bool If False and the dataset has not been downloaded yet, it will not be downloaded and the path will be returned - as ‘’ (empty string). This is mostly used for debugging purposes + as ``‘’`` (empty string). This is mostly used for debugging purposes and can be safely ignored by most users. %(verbose)s diff --git a/mne_icalabel/datasets/icalabel/icalabel.pyi b/mne_icalabel/datasets/icalabel/icalabel.pyi index 2763403c5..7ce23dde5 100644 --- a/mne_icalabel/datasets/icalabel/icalabel.pyi +++ b/mne_icalabel/datasets/icalabel/icalabel.pyi @@ -30,7 +30,7 @@ def data_path( download : bool If False and the dataset has not been downloaded yet, it will not be downloaded and the path will be returned - as ‘’ (empty string). This is mostly used for debugging purposes + as ``‘’`` (empty string). This is mostly used for debugging purposes and can be safely ignored by most users. verbose : bool | str | int | None diff --git a/mne_icalabel/gui/_label_components.pyi b/mne_icalabel/gui/_label_components.pyi index 8cb7a7d3d..1a906d7a8 100644 --- a/mne_icalabel/gui/_label_components.pyi +++ b/mne_icalabel/gui/_label_components.pyi @@ -54,34 +54,46 @@ class ICAComponentLabeler(QMainWindow): - topomap - psd """ + @staticmethod def _check_inst_ica(inst: Union[BaseRaw, BaseEpochs], ica: ICA) -> None: """Check if the ICA was fitted.""" + @property def inst(self) -> Union[BaseRaw, BaseEpochs]: """Instance on which the ICA has been fitted.""" + @property def ica(self) -> ICA: """Fitted ICA decomposition.""" + @property def n_components_(self) -> int: """The number of fitted components.""" + @property def labels(self) -> list[str]: """List of valid labels.""" + @property def selected_component(self) -> int: """IC selected and displayed.""" + def _connect_signals_to_slots(self) -> None: """Connect all the signals and slots of the GUI.""" + def _components_listWidget_clicked(self) -> None: """Update the plots and the saved labels accordingly.""" + def _update_selected_labels(self) -> None: """Update the labels saved.""" + def _reset(self) -> None: """Action of the reset button.""" + def _reset_buttons(self) -> None: """Reset all buttons.""" + def closeEvent(self, event) -> None: """Clean up upon closing the window. From ff858956819bba839a062e01ad3b4a13d5190ef5 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Mon, 5 Feb 2024 15:40:03 +0100 Subject: [PATCH 6/9] avoid shadowing of builtin --- tools/stubgen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/stubgen.py b/tools/stubgen.py index 3676ef2f0..a0d061b8e 100644 --- a/tools/stubgen.py +++ b/tools/stubgen.py @@ -63,5 +63,5 @@ isort.file(stub, config=config_isort) # run ruff to improve stub style -exec = subprocess.run(["ruff", "format", str(directory), "--config", config]) -sys.exit(exec.returncode) +execution = subprocess.run(["ruff", "format", str(directory), "--config", config]) +sys.exit(execution.returncode) From d22657985bc786635e254150f7d221914f4ea7d9 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Mon, 5 Feb 2024 15:40:26 +0100 Subject: [PATCH 7/9] fix tests and pin pytest to 8.0 or above --- mne_icalabel/iclabel/tests/test_label_components.py | 12 ++++-------- pyproject.toml | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mne_icalabel/iclabel/tests/test_label_components.py b/mne_icalabel/iclabel/tests/test_label_components.py index 56ac66c76..f9d5c3e97 100644 --- a/mne_icalabel/iclabel/tests/test_label_components.py +++ b/mne_icalabel/iclabel/tests/test_label_components.py @@ -124,17 +124,13 @@ def test_warnings(): random_state=101, ) ica.fit(raw) - with pytest.warns(RuntimeWarning, match="common average reference"): - raw_copy = raw.copy() - with raw_copy.info._unlock(): - raw_copy.info["custom_ref_applied"] = 0 - iclabel_label_components(raw_copy, ica) - raw.set_eeg_reference("average") - - with pytest.warns(RuntimeWarning, match="not filtered between 1 and 100 Hz"): + with pytest.warns(RuntimeWarning, match="common average reference"), pytest.warns( + RuntimeWarning, match="not filtered between 1 and 100 Hz" + ): iclabel_label_components(raw, ica) with raw.info._unlock(): raw.info["lowpass"] = 100.0 + raw.set_eeg_reference("average") # infomax ica = ICA( diff --git a/pyproject.toml b/pyproject.toml index 3d3349129..b53c426cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,7 +118,7 @@ test = [ 'pandas', 'pymatreader', 'PyQt6', - 'pytest', + 'pytest>=8.0.0', 'pytest-cov', ] torch = [ @@ -185,7 +185,7 @@ match-dir = '^mne_icalabel.*' [tool.pytest.ini_options] addopts = '--durations 20 --junit-xml=junit-results.xml -v --color=yes' junit_family = 'xunit2' -minversion = '6.0' +minversion = '8.0' [tool.ruff] extend-exclude = [ From 5431bdf12a267b6378cd87fd4a32a2017325615e Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Mon, 5 Feb 2024 15:40:36 +0100 Subject: [PATCH 8/9] fix ruff configuration deprecation warnings --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b53c426cb..aabee7920 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -192,15 +192,17 @@ extend-exclude = [ 'doc', 'setup.py', ] -ignore = [] line-length = 88 -select = ["E", "F", "UP", "W"] target-version = 'py39' [tool.ruff.format] docstring-code-format = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint] +ignore = [] +select = ["E", "F", "UP", "W"] + +[tool.ruff.lint.per-file-ignores] '*' = [ "UP007", # 'Use `X | Y` for type annotations', requires python 3.10 ] From 09a454ad28652419399a9fe09e32d005c07b62f2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:00:59 +0000 Subject: [PATCH 9/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aabee7920..31bdc6f1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,8 +118,8 @@ test = [ 'pandas', 'pymatreader', 'PyQt6', - 'pytest>=8.0.0', 'pytest-cov', + 'pytest>=8.0.0', ] torch = [ 'torch',