Skip to content

Commit 101cd24

Browse files
authored
Merge pull request #753 from cmu-delphi/fix_linting
Update makefiles to fix linting failures not failing
2 parents b7b3836 + dbd8227 commit 101cd24

File tree

30 files changed

+83
-94
lines changed

30 files changed

+83
-94
lines changed

_delphi_utils_python/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ install: venv
1111
pip install -e .
1212

1313
lint:
14-
. env/bin/activate; \
15-
pylint $(dir); \
16-
pydocstyle $(dir)
14+
. env/bin/activate; pylint $(dir)
15+
. env/bin/activate; pydocstyle $(dir)
1716

1817
test:
1918
. env/bin/activate ;\

_delphi_utils_python/delphi_utils/export.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ def create_export_csv(
6666
if remove_null_samples:
6767
export_df = export_df[export_df["sample_size"].notnull()]
6868
export_df.to_csv(export_file, index=False, na_rep="NA")
69-
7069
return dates

_delphi_utils_python/delphi_utils/geomap.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ def add_geocode(
306306
df = df.copy()
307307
from_col = from_code if from_col is None else from_col
308308
new_col = new_code if new_col is None else new_col
309-
assert from_col != new_col, f"Can't use the same column '{from_col}' for both from_col and to_col"
309+
assert from_col != new_col, \
310+
f"Can't use the same column '{from_col}' for both from_col and to_col"
310311
state_codes = ["state_code", "state_id", "state_name"]
311312

312313
if not is_string_dtype(df[from_col]):
@@ -325,7 +326,8 @@ def add_geocode(
325326
return df
326327
elif new_code == "nation":
327328
raise ValueError(
328-
f"Conversion to the nation level is not supported from {from_code}; try fips, zip, or state_*"
329+
f"Conversion to the nation level is not supported "
330+
f"from {from_code}; try fips, zip, or state_*"
329331
)
330332

331333
# state codes are all stored in one table

_template_python/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

cdc_covidnet/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

changehc/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

changehc/delphi_changehc/run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,9 @@ def run_module():
150150
su_inst.update_sensor(
151151
data,
152152
params["export_dir"]
153-
)
153+
)
154154
logger.info("finished processing", geo = geo)
155-
155+
156156
elapsed_time_in_seconds = round(time.time() - start_time, 2)
157157
logger.info("Completed indicator run",
158158
elapsed_time_in_seconds = elapsed_time_in_seconds)
159-

claims_hosp/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir)
17-
pylint $(dir); \
18-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1917

2018
test:
2119
. env/bin/activate ;\

combo_cases_and_deaths/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def run_module():
196196
df[df["timestamp"] == date_][["geo_id", "val", "se", "sample_size", ]].to_csv(
197197
f"{export_dir}/{export_fn}", index=False, na_rep="NA"
198198
)
199-
199+
200200
elapsed_time_in_seconds = round(time.time() - start_time, 2)
201201
logger.info("Completed indicator run",
202202
elapsed_time_in_seconds = elapsed_time_in_seconds)

covid_act_now/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

google_health/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1717

1818
test:
1919
. env/bin/activate ;\

google_symptoms/Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
20-
. env/bin/activate ;\
21-
(cd tests && ../env/bin/pytest --cov=$(dir) --cov-report=term-missing)
19+
. env/bin/activate ; (cd tests && ../env/bin/pytest --cov=$(dir) --cov-report=term-missing)
2220

2321
clean:
2422
rm -rf env

google_symptoms/delphi_google_symptoms/run.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
This module should contain a function called `run_module`, that is executed
55
when the module is run with `python -m delphi_google_symptoms`.
66
"""
7+
import time
78
from datetime import datetime
89
from itertools import product
910

1011
import numpy as np
11-
import time
1212
from delphi_utils import (
13-
read_params,
14-
create_export_csv,
13+
read_params,
14+
create_export_csv,
1515
geomap,
1616
get_structured_logger
1717
)
1818

19-
from .pull import pull_gs_data
20-
from .geo import geo_map
2119
from .constants import (METRICS, COMBINED_METRIC,
2220
GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP)
21+
from .geo import geo_map
22+
from .pull import pull_gs_data
2323

2424

2525
def run_module():
@@ -66,7 +66,7 @@ def run_module():
6666
metric=metric.lower(),
6767
geo_res=geo_res,
6868
sensor=sensor_name)
69-
69+
7070
if not exported_csv_dates.empty:
7171
csv_export_count += exported_csv_dates.size
7272
if not oldest_final_export_date:

hhs_facilities/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

hhs_hosp/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

jhu/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

nchs_mortality/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

nowcast/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir) --match-dir '(?!nowcast_fusion)'
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir) --match-dir '(?!nowcast_fusion)'
1817

1918
test:
2019
. env/bin/activate ;\

quidel/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

quidel/delphi_quidel/data_tools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def _prop_var(p, n):
77
"""
88
Calculate variance of proportion.
9-
9+
1010
var(X/n) = 1/(n^2)var(X) = (npq)/(n^2) = pq/n
1111
"""
1212
return p * (1 - p) / n
@@ -64,7 +64,7 @@ def _slide_window_sum(arr, k):
6464

6565
def _geographical_pooling(tpooled_tests, tpooled_ptests, min_obs, max_borrow_obs):
6666
"""
67-
Calculate proportion of parent samples (tests) that must be "borrowed" in order to compute the statistic.
67+
Calculate proportion of parent samples (tests) that must be "borrowed" to compute the statistic.
6868
6969
If there are no samples available in the parent, the borrow_prop is 0. If the parent does not
7070
have enough samples, we return a borrow_prop of 1, and the fact that the
@@ -119,7 +119,7 @@ def _geographical_pooling(tpooled_tests, tpooled_ptests, min_obs, max_borrow_obs
119119

120120
def raw_positive_prop(positives, tests, min_obs):
121121
"""
122-
Calculate the proportion of positive tests for a single geographic location, without any temporal smoothing.
122+
Calculate proportion of positive tests for a single location with no temporal smoothing.
123123
124124
If on any day t, tests[t] < min_obs, then we report np.nan.
125125
@@ -172,7 +172,7 @@ def raw_positive_prop(positives, tests, min_obs):
172172
def smoothed_positive_prop(positives, tests, min_obs, max_borrow_obs, pool_days,
173173
parent_positives=None, parent_tests=None):
174174
"""
175-
Calculate the proportion of negative tests for a single geographic location, with temporal smoothing.
175+
Calculate the proportion of negative tests for a single location with temporal smoothing.
176176
177177
For a given day t, if sum(tests[(t-pool_days+1):(t+1)]) < min_obs, then we
178178
'borrow' min_obs - sum(tests[(t-pool_days+1):(t+1)]) observations from the
@@ -307,7 +307,7 @@ def raw_tests_per_device(devices, tests, min_obs):
307307
def smoothed_tests_per_device(devices, tests, min_obs, max_borrow_obs, pool_days,
308308
parent_devices=None, parent_tests=None):
309309
"""
310-
Calculate the ratio of tests per device for a single geographic location, with temporal smoothing.
310+
Calculate the ratio of tests per device for a single location with temporal smoothing.
311311
312312
For a given day t, if sum(tests[(t-pool_days+1):(t+1)]) < min_obs, then we
313313
'borrow' min_obs - sum(tests[(t-pool_days+1):(t+1)]) observations from the

quidel/delphi_quidel/pull.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def read_historical_data():
6262

6363
def regulate_column_names(df, test_type):
6464
"""
65-
Regulate column names for flu_ag test data since Quidel changed their column names multiple times.
65+
Regulate column names for flu_ag test data since Quidel changed the column names multiple times.
6666
6767
We want to finalize the column name list to be:
6868
['SofiaSerNum', 'TestDate', 'Facility',
@@ -311,7 +311,7 @@ def check_intermediate_file(cache_dir, pull_start_dates):
311311

312312
def pull_quidel_data(params):
313313
"""
314-
Pull the quidel test data and decide whether to combine the new data with stored historical records in ./cache.
314+
Pull new quidel test data and decide whether to combine it with historical records in ./cache.
315315
316316
Parameters:
317317
params: dict
@@ -402,7 +402,10 @@ def check_export_end_date(input_export_end_dates, _end_date,
402402
def check_export_start_date(export_start_dates, export_end_dates,
403403
export_day_range):
404404
"""
405-
Update export_start_date according to the export_end_date so that it could be export_end_date - EXPORT_DAY_RANGE.
405+
Update export_start_date according to the export_end_date.
406+
407+
Update export_start_date according to the export_end_date so that
408+
it could be export_end_date - EXPORT_DAY_RANGE.
406409
407410
Parameters:
408411
export_start_date: dict

quidel/delphi_quidel/run.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@
44
This module should contain a function called `run_module`, that is executed
55
when the module is run with `python -m MODULE_NAME`.
66
"""
7+
import time
78
from os.path import join
89

910
import pandas as pd
10-
import time
1111
from delphi_utils import (
1212
read_params,
1313
add_prefix,
1414
create_export_csv,
1515
get_structured_logger
1616
)
1717

18+
from .constants import (END_FROM_TODAY_MINUS, EXPORT_DAY_RANGE,
19+
GEO_RESOLUTIONS, SENSORS)
20+
from .generate_sensor import (generate_sensor_for_states,
21+
generate_sensor_for_other_geores)
1822
from .geo_maps import geo_map
1923
from .pull import (pull_quidel_data,
2024
check_export_start_date,
2125
check_export_end_date,
2226
update_cache_file)
23-
from .generate_sensor import (generate_sensor_for_states,
24-
generate_sensor_for_other_geores)
25-
from .constants import (END_FROM_TODAY_MINUS, EXPORT_DAY_RANGE,
26-
GEO_RESOLUTIONS, SENSORS)
27+
2728

2829
def run_module():
2930
"""Run Quidel flu test module."""

quidel_covidtest/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ install: venv
1212
pip install -e .
1313

1414
lint:
15-
. env/bin/activate; \
16-
pylint $(dir); \
17-
pydocstyle $(dir)
15+
. env/bin/activate; pylint $(dir)
16+
. env/bin/activate; pydocstyle $(dir)
1817

1918
test:
2019
. env/bin/activate ;\

0 commit comments

Comments
 (0)