Skip to content

Commit a34dd22

Browse files
authored
Merge pull request #561 from cmu-delphi/gsymptoms-docs
Get google symptoms to pass pydocstyle
2 parents 0437403 + 79c481a commit a34dd22

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

google_symptoms/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ install: venv
1313

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

1819
test:
1920
. env/bin/activate ;\

google_symptoms/delphi_google_symptoms/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
"""Module to pull and clean indicators from the Google Research's Open
3-
COVID-19 Data project.
2+
"""Module to pull and clean indicators from the Google Research's Open COVID-19 Data project.
3+
44
This file defines the functions that are made public by the module. As the
55
module is intended to be executed though the main method, these are primarily
66
for testing.

google_symptoms/delphi_google_symptoms/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Registry for constants"""
1+
"""Registry for constants."""
22
from functools import partial
33
from datetime import timedelta
44

google_symptoms/delphi_google_symptoms/geo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
"""Functions for mapping between geo regions."""
12
# -*- coding: utf-8 -*-
23
import numpy as np
34
import pandas as pd
45
from delphi_utils import GeoMapper
56
from .constants import METRICS, COMBINED_METRIC
67

78
gmpr = GeoMapper()
9+
810
def generate_transition_matrix(geo_res):
911
"""
10-
Generate transition matrix from county to msa/hrr
12+
Generate transition matrix from county to msa/hrr.
1113
1214
Parameters
1315
----------

google_symptoms/delphi_google_symptoms/pull.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Retrieve data and wrangle into appropriate format."""
12
# -*- coding: utf-8 -*-
23
import re
34

@@ -8,6 +9,8 @@
89

910
def get_geo_id(region_code):
1011
"""
12+
Extract fips code from region code.
13+
1114
There are region code in the format of "US-state" and "US-state-fips". In
1215
county level report, we only consider rows with fips info provided.
1316
"""
@@ -19,8 +22,7 @@ def get_geo_id(region_code):
1922

2023
def preprocess(df, level):
2124
"""
22-
Conforms the pulled data from Google COVID-19 Search Trends symptoms
23-
data into a dataset
25+
Conforms the pulled data from Google COVID-19 Search Trends symptoms data into a dataset.
2426
2527
The output dataset has:
2628
@@ -90,7 +92,9 @@ def preprocess(df, level):
9092
return df
9193

9294
def pull_gs_data(base_url):
93-
"""Pulls the latest Google COVID-19 Search Trends symptoms dataset, and
95+
"""Pull latest dataset and transform it into the appropriate format.
96+
97+
Pull the latest Google COVID-19 Search Trends symptoms dataset, and
9498
conforms it into a dataset as described in preprocess function.
9599
96100
Note that we retrieve state level data from "2020_US_daily_symptoms_dataset.csv"

google_symptoms/delphi_google_symptoms/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
def run_module():
20-
20+
"""Run Google Symptoms module."""
2121
params = read_params()
2222
export_start_date = datetime.strptime(params["export_start_date"], "%Y-%m-%d")
2323
export_dir = params["export_dir"]

google_symptoms/delphi_google_symptoms/smooth.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
"""Functions for smoothing signals."""
12
# -*- coding: utf-8 -*-
23
import numpy as np
34

45
def identity(x):
5-
'''Trivial "smoother" that does no smoothing.
6+
"""Trivial "smoother" that does no smoothing.
67
78
Parameters
89
----------
@@ -13,11 +14,11 @@ def identity(x):
1314
-------
1415
np.ndarray:
1516
Same as x
16-
'''
17+
"""
1718
return x
1819

1920
def kday_moving_average(x, k):
20-
'''Compute k-day moving average on x.
21+
"""Compute k-day moving average on x.
2122
2223
Parameters
2324
----------
@@ -28,7 +29,7 @@ def kday_moving_average(x, k):
2829
-------
2930
np.ndarray:
3031
k-day moving average. The first k-1 entries are np.nan.
31-
'''
32+
"""
3233
if not isinstance(k, int):
3334
raise ValueError('k must be int.')
3435
# temp = np.append(np.zeros(k - 1), x)

0 commit comments

Comments
 (0)