Skip to content

Commit 158cfcb

Browse files
committed
Fix docstrings to pass pydocstyle
1 parent 0a7865e commit 158cfcb

File tree

5 files changed

+17
-27
lines changed

5 files changed

+17
-27
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: 8 additions & 13 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,7 +38,8 @@ 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
41+
Read the mappings JSON file from disk to produce formatted.
42+
4543
pd.DataFrame for relevant mappings
4644
4745
Args:
@@ -52,7 +50,6 @@ def read_mappings(infile: str) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame
5250
mmwr_info: Date-related mappings
5351
catchment_info: Geography-related mappings
5452
"""
55-
5653
with open(infile, "r") as f_json:
5754
data = json.load(f_json)
5855

@@ -76,7 +73,8 @@ def download_hosp_data(
7673
outfile: str,
7774
url: str = APIConfig.HOSP_URL):
7875
"""
79-
Downloads hospitalization data to disk for a particular network or state
76+
Download hospitalization data to disk for a particular network or state.
77+
8078
Refer to catchment_info for network & catchment ID mappings
8179
Refer to age_info for age-group mappings
8280
Seasons are enumerated in original mappings JSON file
@@ -89,7 +87,6 @@ def download_hosp_data(
8987
outfile: JSON file to write the results to
9088
url: The API URL to POST to for downloading hospitalization data
9189
"""
92-
9390
download_params = {
9491
"AppVersion": "Public",
9592
"networkid": network_id,
@@ -108,7 +105,7 @@ def download_all_hosp_data(
108105
mappings_file: str, cache_path: str, parallel: bool = False
109106
) -> List[str]:
110107
"""
111-
Downloads hospitalization data for all states listed in the mappings JSON file to disk.
108+
Download hospitalization data for all states listed in the mappings JSON file to disk.
112109
113110
Args:
114111
mappings_file: Mappings JSON file
@@ -118,7 +115,6 @@ def download_all_hosp_data(
118115
Returns:
119116
List of all downloaded JSON filenames (including the cache_path)
120117
"""
121-
122118
catchment_info, _, age_info = CovidNet.read_mappings(mappings_file)
123119

124120
# By state
@@ -159,15 +155,14 @@ def download_all_hosp_data(
159155
@staticmethod
160156
def read_all_hosp_data(state_files: List[str]) -> pd.DataFrame:
161157
"""
162-
Read and combine hospitalization JSON files for each state into a pd.DataFrame
158+
Read and combine hospitalization JSON files for each state into a pd.DataFrame.
163159
164160
Args:
165161
state_files: List of hospitalization JSON files for each state to read from disk
166162
167163
Returns:
168164
Single pd.DataFrame with all the hospitalization data combined
169165
"""
170-
171166
dfs = []
172167
for state_file in state_files:
173168
# 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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
def write_to_csv(data: pd.DataFrame, out_name: str, output_path: str):
2222
"""
2323
Write sensor values to csv.
24+
2425
The dataframe be indexed by (date, geo_id), with columns
2526
values, se, sample_size
2627
@@ -29,7 +30,6 @@ def write_to_csv(data: pd.DataFrame, out_name: str, output_path: str):
2930
output_name: Suffix name to add to each output file
3031
output_path: Path to write the csvs to
3132
"""
32-
3333
# Each date is a csv file
3434
dates = data.index.get_level_values("date").unique()
3535
for date in dates:
@@ -109,7 +109,8 @@ def update_sensor(
109109

110110

111111
def add_prefix(signal_names, wip_signal, prefix):
112-
"""Adds prefix to signal if there is a WIP signal
112+
"""Add prefix to signal if there is a WIP signal.
113+
113114
Parameters
114115
----------
115116
signal_names: List[str]
@@ -125,7 +126,6 @@ def add_prefix(signal_names, wip_signal, prefix):
125126
List of signal names
126127
wip/non wip signals for further computation
127128
"""
128-
129129
if wip_signal is True:
130130
return [prefix + signal for signal in signal_names]
131131
if isinstance(wip_signal, list):
@@ -144,7 +144,8 @@ def add_prefix(signal_names, wip_signal, prefix):
144144

145145

146146
def public_signal(signal_):
147-
"""Checks if the signal name is already public using COVIDcast
147+
"""Check if the signal name is already public using COVIDcast.
148+
148149
Parameters
149150
----------
150151
signal_ : str

0 commit comments

Comments
 (0)