Skip to content

Commit 3dca3f3

Browse files
authored
Merge pull request #374 from cmu-delphi/cdc_covidnet-docs
Update cdccovidnet docstrings to pass pydocstyle
2 parents 756d5c4 + e3d66d5 commit 3dca3f3

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

cdc_covidnet/delphi_cdc_covidnet/api_config.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"""
77

88
class APIConfig:
9-
"""
10-
Static configuration variables
11-
"""
9+
"""Static configuration variables."""
10+
1211
# API Parameters
1312
INIT_URL = "https://gis.cdc.gov/grasp/covid19_3_api/GetPhase03InitApp"
1413
MMWR_COLS = ["year", "weeknumber", "weekstart", "weekend"]
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
"""
2-
Registry for signal names
3-
"""
1+
"""Registry for signal names."""
42
COVIDNET = "covidnet"
53
SIGNALS = [COVIDNET]

cdc_covidnet/delphi_cdc_covidnet/covidnet.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,19 @@
1717
from .api_config import APIConfig
1818

1919
class CovidNet:
20-
"""
21-
Methods for downloading and loading COVID-NET data
22-
"""
20+
"""Methods for downloading and loading COVID-NET data."""
2321

2422
@staticmethod
2523
def download_mappings(
2624
url: str = APIConfig.INIT_URL,
2725
outfile: str = "./init.json"):
2826
"""
29-
Downloads the JSON file with all mappings (age, mmwr, catchments etc.) to disk
27+
Download the JSON file with all mappings (age, mmwr, catchments etc.) to disk.
3028
3129
Args:
3230
url: The API URL to GET from
3331
outfile: The output JSON file to write to
3432
"""
35-
3633
params = {"appVersion": "Public"}
3734
data = requests.get(url, params).json()
3835
with open(outfile, "w") as f_json:
@@ -41,8 +38,7 @@ def download_mappings(
4138
@staticmethod
4239
def read_mappings(infile: str) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]:
4340
"""
44-
Reads the mappings JSON file from disk to produce formatted
45-
pd.DataFrame for relevant mappings
41+
Read the mappings JSON file from disk to produce formatted DataFrames for relevant mappings.
4642
4743
Args:
4844
infile: Mappings JSON file
@@ -52,7 +48,6 @@ def read_mappings(infile: str) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame
5248
mmwr_info: Date-related mappings
5349
catchment_info: Geography-related mappings
5450
"""
55-
5651
with open(infile, "r") as f_json:
5752
data = json.load(f_json)
5853

@@ -76,7 +71,8 @@ def download_hosp_data(
7671
outfile: str,
7772
url: str = APIConfig.HOSP_URL):
7873
"""
79-
Downloads hospitalization data to disk for a particular network or state
74+
Download hospitalization data to disk for a particular network or state.
75+
8076
Refer to catchment_info for network & catchment ID mappings
8177
Refer to age_info for age-group mappings
8278
Seasons are enumerated in original mappings JSON file
@@ -89,7 +85,6 @@ def download_hosp_data(
8985
outfile: JSON file to write the results to
9086
url: The API URL to POST to for downloading hospitalization data
9187
"""
92-
9388
download_params = {
9489
"AppVersion": "Public",
9590
"networkid": network_id,
@@ -108,7 +103,7 @@ def download_all_hosp_data(
108103
mappings_file: str, cache_path: str, parallel: bool = False
109104
) -> List[str]:
110105
"""
111-
Downloads hospitalization data for all states listed in the mappings JSON file to disk.
106+
Download hospitalization data for all states listed in the mappings JSON file to disk.
112107
113108
Args:
114109
mappings_file: Mappings JSON file
@@ -118,7 +113,6 @@ def download_all_hosp_data(
118113
Returns:
119114
List of all downloaded JSON filenames (including the cache_path)
120115
"""
121-
122116
catchment_info, _, age_info = CovidNet.read_mappings(mappings_file)
123117

124118
# By state
@@ -159,15 +153,14 @@ def download_all_hosp_data(
159153
@staticmethod
160154
def read_all_hosp_data(state_files: List[str]) -> pd.DataFrame:
161155
"""
162-
Read and combine hospitalization JSON files for each state into a pd.DataFrame
156+
Read and combine hospitalization JSON files for each state into a pd.DataFrame.
163157
164158
Args:
165159
state_files: List of hospitalization JSON files for each state to read from disk
166160
167161
Returns:
168162
Single pd.DataFrame with all the hospitalization data combined
169163
"""
170-
171164
dfs = []
172165
for state_file in state_files:
173166
# Read json

cdc_covidnet/delphi_cdc_covidnet/run.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717

1818
def run_module():
19-
"""
20-
Parse parameters and generates csv files for the COVID-NET sensor
21-
"""
22-
19+
"""Parse parameters and generates csv files for the COVID-NET sensor."""
2320
params = read_params()
2421

2522
logging.basicConfig(level=logging.DEBUG)

cdc_covidnet/delphi_cdc_covidnet/update_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
def write_to_csv(data: pd.DataFrame, out_name: str, output_path: str):
2121
"""
2222
Write sensor values to csv.
23+
2324
The dataframe be indexed by (date, geo_id), with columns
2425
values, se, sample_size
2526
@@ -28,7 +29,6 @@ def write_to_csv(data: pd.DataFrame, out_name: str, output_path: str):
2829
output_name: Suffix name to add to each output file
2930
output_path: Path to write the csvs to
3031
"""
31-
3232
# Each date is a csv file
3333
dates = data.index.get_level_values("date").unique()
3434
for date in dates:

0 commit comments

Comments
 (0)