Skip to content

Commit 7e9e6cb

Browse files
authored
Merge pull request #454 from cmu-delphi/nchs-list
Fix linting for nchs
2 parents a3a9131 + 86a56b6 commit 7e9e6cb

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

nchs_mortality/delphi_nchs_mortality/pull.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ def pull_nchs_mortality_data(token: str, map_df: pd.DataFrame, test_mode: str):
3333
Dataframe as described above.
3434
"""
3535
# Constants
36-
KEEP_COLUMNS = ['covid_deaths', 'total_deaths',
36+
keep_columns = ['covid_deaths', 'total_deaths',
3737
'percent_of_expected_deaths', 'pneumonia_deaths',
3838
'pneumonia_and_covid_deaths', 'influenza_deaths',
3939
'pneumonia_influenza_or_covid_19_deaths']
40-
TYPE_DICT = {key: float for key in KEEP_COLUMNS}
41-
TYPE_DICT["timestamp"] = 'datetime64[ns]'
40+
type_dict = {key: float for key in keep_columns}
41+
type_dict["timestamp"] = 'datetime64[ns]'
4242

4343
if test_mode == "":
4444
# Pull data from Socrata API
@@ -52,18 +52,18 @@ def pull_nchs_mortality_data(token: str, map_df: pd.DataFrame, test_mode: str):
5252
# Check missing start_week == end_week
5353
try:
5454
assert sum(df["timestamp"] != df["end_week"]) == 0
55-
except AssertionError:
55+
except AssertionError as exc:
5656
raise ValueError(
5757
"end_week is not always the same as start_week, check the raw file"
58-
)
58+
) from exc
5959

6060
try:
61-
df = df.astype(TYPE_DICT)
62-
except KeyError:
61+
df = df.astype(type_dict)
62+
except KeyError as exc:
6363
raise ValueError("Expected column(s) missed, The dataset "
64-
"schema may have changed. Please investigate and "
65-
"amend the code.")
66-
64+
"schema may have changed. Please investigate and "
65+
"amend the code.") from exc
66+
6767
df = df[df["state"] != "United States"]
6868
df.loc[df["state"] == "New York City", "state"] = "New York"
6969

@@ -91,7 +91,7 @@ def pull_nchs_mortality_data(token: str, map_df: pd.DataFrame, test_mode: str):
9191
)
9292

9393
# Add population info
94-
KEEP_COLUMNS.extend(["timestamp", "geo_id", "population"])
95-
df = df.merge(map_df, on="state")[KEEP_COLUMNS]
96-
94+
keep_columns.extend(["timestamp", "geo_id", "population"])
95+
df = df.merge(map_df, on="state")[keep_columns]
96+
9797
return df

nchs_mortality/delphi_nchs_mortality/run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"prop"
2828
]
2929
INCIDENCE_BASE = 100000
30-
geo_res = "state"
30+
GEO_RES = "state"
3131

32-
def run_module():
32+
def run_module(): # pylint: disable=too-many-branches,too-many-statements
3333
"""Run module for processing NCHS mortality data."""
3434
params = read_params()
3535
export_start_date = params["export_start_date"]
@@ -65,7 +65,7 @@ def run_module():
6565
sensor_name = "_".join(["wip", metric])
6666
export_csv(
6767
df,
68-
geo_name=geo_res,
68+
geo_name=GEO_RES,
6969
export_dir=daily_export_dir,
7070
start_date=datetime.strptime(export_start_date, "%Y-%m-%d"),
7171
sensor=sensor_name,
@@ -82,7 +82,7 @@ def run_module():
8282
sensor_name = "_".join(["wip", metric, sensor])
8383
export_csv(
8484
df,
85-
geo_name=geo_res,
85+
geo_name=GEO_RES,
8686
export_dir=daily_export_dir,
8787
start_date=datetime.strptime(export_start_date, "%Y-%m-%d"),
8888
sensor=sensor_name,
@@ -104,7 +104,7 @@ def run_module():
104104
params["aws_credentials"])
105105

106106
# Dont update cache from S3 (has daily files), only simulate a update_cache() call
107-
weekly_arch_diff._cache_updated = True
107+
weekly_arch_diff._cache_updated = True # pylint: disable=protected-access
108108

109109
# Diff exports, and make incremental versions
110110
_, common_diffs, new_files = weekly_arch_diff.diff_exports()

0 commit comments

Comments
 (0)