Skip to content

Commit fbb87bd

Browse files
authored
Merge pull request #118 from CardiacModelling/coverage-2
Separate summarise-herg-qc script command line parsing
2 parents 60e55ff + 031e88b commit fbb87bd

File tree

7 files changed

+368
-244
lines changed

7 files changed

+368
-244
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ jobs:
4848
wget https://cardiac.nottingham.ac.uk/syncropatch_export/test_data.tar.xz -P tests/
4949
tar xvf tests/test_data.tar.xz -C tests/
5050
51+
- name: Install TeX dependencies for run_herg_qc test
52+
timeout-minutes: 5
53+
run: sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super -y
54+
5155
- name: Run unit tests (without coverage testing)
5256
if: ${{ success() && matrix.python-version != env.python-latest }}
5357
run: python -m unittest
@@ -56,14 +60,6 @@ jobs:
5660
if: ${{ success() && matrix.python-version == env.python-latest }}
5761
run: coverage run -m unittest
5862

59-
- name: Install TeX dependencies for run_herg_qc test
60-
timeout-minutes: 15
61-
run: sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super -y
62-
63-
- name: Run `run_herg_qc` script
64-
timeout-minutes: 15
65-
run: pcpostprocess run_herg_qc tests/test_data/13112023_MW2_FF -w A01 A02 A03
66-
6763
- name: Report coverage to codecov
6864
uses: codecov/codecov-action@v4
6965
if: ${{ success() && matrix.python-version == env.python-latest }}

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Isort is configured in [pyproject.toml](./pyproject.toml) under the section `too
7676
## Documentation
7777

7878
Every method and every class should have a [docstring](https://www.python.org/dev/peps/pep-0257/) that describes in plain terms what it does, and what the expected input and output is.
79+
The only exception are unit test methods starting with `test_` - unit test classes and other methods in unit tests should all have docstrings.
7980

8081
Each docstring should start with a one-line explanation.
8182
If more explanation is needed, this one-liner is followed by a blank line and more information in the following paragraphs.

pcpostprocess/scripts/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main():
2121
run_herg_qc.run_from_command_line()
2222

2323
elif args.subcommand == "summarise_herg_export":
24-
summarise_herg_export.main()
24+
summarise_herg_export.run_from_command_line()
2525

2626

2727
if __name__ == "__main__":

pcpostprocess/scripts/run_herg_qc.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import string
1212
import sys
1313

14-
import cycler
1514
import matplotlib
1615
import matplotlib.pyplot as plt
1716
import numpy as np
@@ -28,17 +27,11 @@
2827
from pcpostprocess.leak_correct import fit_linear_leak, get_leak_corrected
2928
from pcpostprocess.subtraction_plots import do_subtraction_plot
3029

31-
# TODO: Remove this
32-
color_cycle = ["#5790fc", "#f89c20", "#e42536", "#964a8b", "#9c9ca1", "#7a21dd"]
33-
plt.rcParams['axes.prop_cycle'] = cycler.cycler('color', color_cycle)
34-
35-
# TODO: Not sure we need to explicitly set this!
36-
matplotlib.use('Agg')
37-
3830

3931
def run_from_command_line():
4032
"""
41-
Reads arguments from the command line and runs herg QC.
33+
Reads arguments from the command line and an ``export_config.py`` and then
34+
runs herg QC.
4235
"""
4336

4437
parser = argparse.ArgumentParser()
@@ -109,11 +102,7 @@ def run(data_path, output_path, qc_map, wells=None,
109102
write_traces=False, write_failed_traces=False, write_map={},
110103
reversal_potential=-90, reversal_spread_threshold=10,
111104
max_processes=1, figure_size=None,
112-
debug=False,
113-
114-
save_id=None,
115-
116-
):
105+
debug=False, save_id=None):
117106
"""
118107
Imports traces and runs QC.
119108
@@ -148,6 +137,9 @@ def run(data_path, output_path, qc_map, wells=None,
148137
# TODO Remove protocol selection here: this is done via the export file!
149138
# Only protocols listed there are accepted
150139

140+
# TODO: Find some way around setting this?
141+
matplotlib.use('Agg')
142+
151143
# Select wells to use
152144
all_wells = [row + str(i).zfill(2) for row in string.ascii_uppercase[:16]
153145
for i in range(1, 25)]
@@ -503,8 +495,6 @@ def agg_func(x):
503495
qc_df['protocol'] = ['staircaseramp1_2' if p == 'staircaseramp2' else p
504496
for p in qc_df.protocol]
505497

506-
print(qc_df.protocol.unique())
507-
508498
fails_dict = {}
509499
no_wells = 384
510500

@@ -1255,7 +1245,7 @@ def fit_func(x, args=None):
12551245
]
12561246

12571247
# TESTING ONLY
1258-
np.random.seed(1)
1248+
# np.random.seed(1)
12591249

12601250
#  Repeat optimisation with different starting guesses
12611251
x0s = [[np.random.uniform(lower_b, upper_b) for lower_b, upper_b in bounds] for i in range(100)]

0 commit comments

Comments
 (0)