From af83628b975d6d1dad75ddaede162a7af3afb7e4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 16:32:51 +0000 Subject: [PATCH 1/9] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) - https://github.com/psf/black → https://github.com/psf/black-pre-commit-mirror - [github.com/psf/black-pre-commit-mirror: 24.8.0 → 26.3.1](https://github.com/psf/black-pre-commit-mirror/compare/24.8.0...26.3.1) - [github.com/PyCQA/flake8: 7.1.1 → 7.3.0](https://github.com/PyCQA/flake8/compare/7.1.1...7.3.0) - [github.com/pycqa/isort: 5.13.2 → 8.0.1](https://github.com/pycqa/isort/compare/5.13.2...8.0.1) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a44948..64d8eb6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,22 +4,22 @@ fail_fast: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 24.8.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.3.1 hooks: - id: black args: [--line-length=128, --verbose] - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 + rev: 7.3.0 hooks: - id: flake8 args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231,E731', --count, --statistics, --show-source] - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 8.0.1 hooks: - id: isort args: [--profile=black, --line-length=128] From fdad28da50f10b5a9e057949830935d61da17b76 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 16:33:28 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cfg.py | 3 +-- data_reader.py | 3 +-- dataset.py | 8 ++------ gather_results.py | 3 +-- sample_data/__init__.py | 3 +-- test_entry.py | 3 +-- trainer.py | 21 +++++++-------------- utils/__init__.py | 3 +-- utils/misc.py | 3 +-- utils/scoring_metrics_test.py | 11 +++-------- utils/utils_interval.py | 1 + 11 files changed, 20 insertions(+), 42 deletions(-) diff --git a/cfg.py b/cfg.py index 8ba0aa0..685bc25 100644 --- a/cfg.py +++ b/cfg.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import os from copy import deepcopy diff --git a/data_reader.py b/data_reader.py index 95c6216..7623d7e 100644 --- a/data_reader.py +++ b/data_reader.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -""" -""" +""" """ import json import logging diff --git a/dataset.py b/dataset.py index 649a640..8735dc3 100644 --- a/dataset.py +++ b/dataset.py @@ -1252,14 +1252,10 @@ def _train_test_split(self, train_ratio: float = 0.8, force_recompute: bool = Fa with open(test_file_1, "w") as f1, open(test_file_2, "w") as f2: json.dump(test_set, f1, ensure_ascii=False) json.dump(test_set, f2, ensure_ascii=False) - print( - nildent( - f""" + print(nildent(f""" train set saved to \n\042{train_file_1}\042and\n\042{train_file_2}\042 test set saved to \n\042{test_file_1}\042and\n\042{test_file_2}\042 - """ - ) - ) + """)) else: with open(train_file, "r") as f: train_set = json.load(f) diff --git a/gather_results.py b/gather_results.py index db4ee70..35f48a5 100644 --- a/gather_results.py +++ b/gather_results.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import glob import json diff --git a/sample_data/__init__.py b/sample_data/__init__.py index daf2131..7d0f61f 100644 --- a/sample_data/__init__.py +++ b/sample_data/__init__.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import glob import os diff --git a/test_entry.py b/test_entry.py index 02a6375..e0ea602 100644 --- a/test_entry.py +++ b/test_entry.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import glob import os diff --git a/trainer.py b/trainer.py index 38bf605..ccbb440 100644 --- a/trainer.py +++ b/trainer.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import argparse import logging @@ -149,8 +148,7 @@ def train( comment=f"OPT_{config.task}_{_model.__name__}{cnn_name}{rnn_name}{attn_name}_{config.train_optimizer}_LR_{lr}_BS_{batch_size}", ) - msg = textwrap.dedent( - f""" + msg = textwrap.dedent(f""" Starting training: ------------------ Task: {config.task} @@ -163,8 +161,7 @@ def train( Optimizer: {config.train_optimizer} Dataset classes: {train_dataset.all_classes} --------------------------------------------------- - """ - ) + """) if logger: logger.info(msg) @@ -347,15 +344,13 @@ def train( else: eval_train_msg = "" for k, v in eval_res.items(): - msg = textwrap.dedent( - f""" + msg = textwrap.dedent(f""" Train epoch_{epoch + 1}: -------------------- train/epoch_loss: {epoch_loss}{eval_train_msg} test/task_metric_{k}: {v} --------------------------------- - """ - ) + """) if logger: logger.info(msg) else: @@ -378,12 +373,10 @@ def train( print(msg) break - msg = textwrap.dedent( - f""" + msg = textwrap.dedent(f""" best metric = {best_metric}, obtained at epoch {best_epoch} - """ - ) + """) if logger: logger.info(msg) else: diff --git a/utils/__init__.py b/utils/__init__.py index cd7d3cb..2de9e21 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import os import sys diff --git a/utils/misc.py b/utils/misc.py index 9951486..b632a9b 100644 --- a/utils/misc.py +++ b/utils/misc.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import datetime import json diff --git a/utils/scoring_metrics_test.py b/utils/scoring_metrics_test.py index fd1b29d..16aee6e 100644 --- a/utils/scoring_metrics_test.py +++ b/utils/scoring_metrics_test.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import argparse import glob @@ -165,14 +164,10 @@ def run_single_test(rec: str, classes: Optional[List[str]] = None, verbose: bool return print(f" {os.path.basename(rec)} starts ".center(30, "-")) - print( - textwrap.dedent( - f""" + print(textwrap.dedent(f""" record = {os.path.basename(rec)}, class = {header.comments[0]}, - """ - ) - ) + """)) custom_onset_scoring_mask, custom_offset_scoring_mask = gen_endpoint_score_mask( siglen=header.sig_len, diff --git a/utils/utils_interval.py b/utils/utils_interval.py index 83eb024..406b213 100644 --- a/utils/utils_interval.py +++ b/utils/utils_interval.py @@ -10,6 +10,7 @@ 2. distinguish openness and closedness """ + import time from copy import deepcopy from numbers import Real From e24ee89bf2eb31bef99dfc0213d73e7b21b53403 Mon Sep 17 00:00:00 2001 From: WEN Hao <8778305+wenh06@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:54:25 +0000 Subject: [PATCH 3/9] update pre-commit config --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64d8eb6..89f79f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: rev: 7.3.0 hooks: - id: flake8 - args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231,E731', --count, --statistics, --show-source] + args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231,E731,E226', --count, --statistics, --show-source] - repo: https://github.com/pycqa/isort rev: 8.0.1 hooks: From 1ee86d8193a60205afb8edf5681db7b910db8535 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 16:32:23 +0000 Subject: [PATCH 4/9] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) - https://github.com/psf/black → https://github.com/psf/black-pre-commit-mirror - [github.com/psf/black-pre-commit-mirror: 24.8.0 → 26.3.1](https://github.com/psf/black-pre-commit-mirror/compare/24.8.0...26.3.1) - [github.com/PyCQA/flake8: 7.1.1 → 7.3.0](https://github.com/PyCQA/flake8/compare/7.1.1...7.3.0) - [github.com/pycqa/isort: 5.13.2 → 8.0.1](https://github.com/pycqa/isort/compare/5.13.2...8.0.1) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a44948..64d8eb6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,22 +4,22 @@ fail_fast: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 24.8.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.3.1 hooks: - id: black args: [--line-length=128, --verbose] - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 + rev: 7.3.0 hooks: - id: flake8 args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231,E731', --count, --statistics, --show-source] - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 8.0.1 hooks: - id: isort args: [--profile=black, --line-length=128] From 18abee644fa96d8a73cce3cca395ba5785b17d52 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 16:32:50 +0000 Subject: [PATCH 5/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cfg.py | 3 +-- data_reader.py | 3 +-- dataset.py | 8 ++------ gather_results.py | 3 +-- sample_data/__init__.py | 3 +-- test_entry.py | 3 +-- trainer.py | 21 +++++++-------------- utils/__init__.py | 3 +-- utils/misc.py | 3 +-- utils/scoring_metrics_test.py | 11 +++-------- utils/utils_interval.py | 1 + 11 files changed, 20 insertions(+), 42 deletions(-) diff --git a/cfg.py b/cfg.py index 8ba0aa0..685bc25 100644 --- a/cfg.py +++ b/cfg.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import os from copy import deepcopy diff --git a/data_reader.py b/data_reader.py index 95c6216..7623d7e 100644 --- a/data_reader.py +++ b/data_reader.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -""" -""" +""" """ import json import logging diff --git a/dataset.py b/dataset.py index 649a640..8735dc3 100644 --- a/dataset.py +++ b/dataset.py @@ -1252,14 +1252,10 @@ def _train_test_split(self, train_ratio: float = 0.8, force_recompute: bool = Fa with open(test_file_1, "w") as f1, open(test_file_2, "w") as f2: json.dump(test_set, f1, ensure_ascii=False) json.dump(test_set, f2, ensure_ascii=False) - print( - nildent( - f""" + print(nildent(f""" train set saved to \n\042{train_file_1}\042and\n\042{train_file_2}\042 test set saved to \n\042{test_file_1}\042and\n\042{test_file_2}\042 - """ - ) - ) + """)) else: with open(train_file, "r") as f: train_set = json.load(f) diff --git a/gather_results.py b/gather_results.py index db4ee70..35f48a5 100644 --- a/gather_results.py +++ b/gather_results.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import glob import json diff --git a/sample_data/__init__.py b/sample_data/__init__.py index daf2131..7d0f61f 100644 --- a/sample_data/__init__.py +++ b/sample_data/__init__.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import glob import os diff --git a/test_entry.py b/test_entry.py index 02a6375..e0ea602 100644 --- a/test_entry.py +++ b/test_entry.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import glob import os diff --git a/trainer.py b/trainer.py index 38bf605..ccbb440 100644 --- a/trainer.py +++ b/trainer.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import argparse import logging @@ -149,8 +148,7 @@ def train( comment=f"OPT_{config.task}_{_model.__name__}{cnn_name}{rnn_name}{attn_name}_{config.train_optimizer}_LR_{lr}_BS_{batch_size}", ) - msg = textwrap.dedent( - f""" + msg = textwrap.dedent(f""" Starting training: ------------------ Task: {config.task} @@ -163,8 +161,7 @@ def train( Optimizer: {config.train_optimizer} Dataset classes: {train_dataset.all_classes} --------------------------------------------------- - """ - ) + """) if logger: logger.info(msg) @@ -347,15 +344,13 @@ def train( else: eval_train_msg = "" for k, v in eval_res.items(): - msg = textwrap.dedent( - f""" + msg = textwrap.dedent(f""" Train epoch_{epoch + 1}: -------------------- train/epoch_loss: {epoch_loss}{eval_train_msg} test/task_metric_{k}: {v} --------------------------------- - """ - ) + """) if logger: logger.info(msg) else: @@ -378,12 +373,10 @@ def train( print(msg) break - msg = textwrap.dedent( - f""" + msg = textwrap.dedent(f""" best metric = {best_metric}, obtained at epoch {best_epoch} - """ - ) + """) if logger: logger.info(msg) else: diff --git a/utils/__init__.py b/utils/__init__.py index cd7d3cb..2de9e21 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import os import sys diff --git a/utils/misc.py b/utils/misc.py index 9951486..b632a9b 100644 --- a/utils/misc.py +++ b/utils/misc.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import datetime import json diff --git a/utils/scoring_metrics_test.py b/utils/scoring_metrics_test.py index fd1b29d..16aee6e 100644 --- a/utils/scoring_metrics_test.py +++ b/utils/scoring_metrics_test.py @@ -1,5 +1,4 @@ -""" -""" +""" """ import argparse import glob @@ -165,14 +164,10 @@ def run_single_test(rec: str, classes: Optional[List[str]] = None, verbose: bool return print(f" {os.path.basename(rec)} starts ".center(30, "-")) - print( - textwrap.dedent( - f""" + print(textwrap.dedent(f""" record = {os.path.basename(rec)}, class = {header.comments[0]}, - """ - ) - ) + """)) custom_onset_scoring_mask, custom_offset_scoring_mask = gen_endpoint_score_mask( siglen=header.sig_len, diff --git a/utils/utils_interval.py b/utils/utils_interval.py index 83eb024..406b213 100644 --- a/utils/utils_interval.py +++ b/utils/utils_interval.py @@ -10,6 +10,7 @@ 2. distinguish openness and closedness """ + import time from copy import deepcopy from numbers import Real From 6f6cced57162ecd671c286f51579017eaa0c8fa1 Mon Sep 17 00:00:00 2001 From: WEN Hao <8778305+wenh06@users.noreply.github.com> Date: Tue, 24 Mar 2026 03:28:14 +0000 Subject: [PATCH 6/9] update python version matrix in action workflow files --- .github/workflows/check-formatting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index 80f23f7..79c3d35 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [3.8, 3.9] + python-version: ["3.10", "3.12"] steps: - uses: actions/checkout@v4 From 89504d26e6c9916a066ad3f39cb805d318fc1b06 Mon Sep 17 00:00:00 2001 From: WEN Hao <8778305+wenh06@users.noreply.github.com> Date: Tue, 24 Mar 2026 03:35:02 +0000 Subject: [PATCH 7/9] update precommit config --- .github/workflows/check-formatting.yml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index 79c3d35..fe9c8dc 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -13,7 +13,7 @@ jobs: build: if: contains(fromJson('["wenh06", "DeepPSP"]'), github.repository_owner) - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: python-version: ["3.10", "3.12"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89f79f6..9f5520b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: rev: 7.3.0 hooks: - id: flake8 - args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231,E731,E226', --count, --statistics, --show-source] + args: [--max-line-length=128, '--exclude=./.*,build,dist,official*,torch_ecg,references,*.ipynb', '--ignore=E501,W503,E203,F841,E402,E231,E731,E226,E225', --count, --statistics, --show-source] - repo: https://github.com/pycqa/isort rev: 8.0.1 hooks: From dc316fb8c03117877fd3436105b4a7c6fe8af52d Mon Sep 17 00:00:00 2001 From: WEN Hao <8778305+wenh06@users.noreply.github.com> Date: Tue, 24 Mar 2026 03:37:53 +0000 Subject: [PATCH 8/9] update requirements --- requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index ad922b8..e8520f8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ -numpy==1.22.0 -scipy==1.6.1 -joblib==1.2.0 +numpy +scipy +joblib # Cython==0.29.10 -pandas==1.2.2 -scikit-learn==0.24.1 -wfdb==3.2.0 +pandas<3.0.0 +scikit-learn +wfdb # biosppy==0.6.1 biosppy opencv-python @@ -12,7 +12,7 @@ opencv-python # keras==2.3.1 packaging easydict -torch==1.8.0 # see Dockerfile +torch torchsummary tensorboardX tqdm From bd3631ff006c029c9eb612759937a993d9d3cc86 Mon Sep 17 00:00:00 2001 From: WEN Hao <8778305+wenh06@users.noreply.github.com> Date: Tue, 24 Mar 2026 03:41:55 +0000 Subject: [PATCH 9/9] update dependencies in action workflow files --- .github/workflows/check-formatting.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index fe9c8dc..8ff22da 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -28,7 +28,5 @@ jobs: run: | python -m pip install --upgrade pip setuptools wheel python -m pip install -r requirements.txt - python -m pip install importlib-metadata==4.8.3 # Testing packages - python -m pip install torch==1.10.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html - name: Check code format with pre-commit uses: pre-commit/action@v3.0.1