Skip to content
Merged
6 changes: 2 additions & 4 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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.8, 3.9]
python-version: ["3.10", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -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
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
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: 5.13.2
rev: 8.0.1
hooks:
- id: isort
args: [--profile=black, --line-length=128]
3 changes: 1 addition & 2 deletions cfg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
from copy import deepcopy
Expand Down
3 changes: 1 addition & 2 deletions data_reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""
"""
""" """

import json
import logging
Expand Down
8 changes: 2 additions & 6 deletions dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions gather_results.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import glob
import json
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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
# tensorflow==1.15.2
# keras==2.3.1
packaging
easydict
torch==1.8.0 # see Dockerfile
torch
torchsummary
tensorboardX
tqdm
Expand Down
3 changes: 1 addition & 2 deletions sample_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import glob
import os
Expand Down
3 changes: 1 addition & 2 deletions test_entry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import glob
import os
Expand Down
21 changes: 7 additions & 14 deletions trainer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import argparse
import logging
Expand Down Expand Up @@ -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}
Expand All @@ -163,8 +161,7 @@ def train(
Optimizer: {config.train_optimizer}
Dataset classes: {train_dataset.all_classes}
---------------------------------------------------
"""
)
""")

if logger:
logger.info(msg)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import os
import sys
Expand Down
3 changes: 1 addition & 2 deletions utils/misc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import datetime
import json
Expand Down
11 changes: 3 additions & 8 deletions utils/scoring_metrics_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
"""
""" """

import argparse
import glob
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions utils/utils_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
2. distinguish openness and closedness

"""

import time
from copy import deepcopy
from numbers import Real
Expand Down
Loading