Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 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.1.0
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: 7.0.0
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
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