File tree Expand file tree Collapse file tree 7 files changed +21
-13
lines changed Expand file tree Collapse file tree 7 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ install: venv
13
13
14
14
lint :
15
15
. env/bin/activate; \
16
- pylint $(dir )
16
+ pylint $(dir ) ; \
17
+ pydocstyle $(dir )
17
18
18
19
test :
19
20
. env/bin/activate ; \
Original file line number Diff line number Diff line change 1
1
# -*- 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
+
4
4
This file defines the functions that are made public by the module. As the
5
5
module is intended to be executed though the main method, these are primarily
6
6
for testing.
Original file line number Diff line number Diff line change 1
- """Registry for constants"""
1
+ """Registry for constants. """
2
2
from functools import partial
3
3
from datetime import timedelta
4
4
Original file line number Diff line number Diff line change
1
+ """Functions for mapping between geo regions."""
1
2
# -*- coding: utf-8 -*-
2
3
import numpy as np
3
4
import pandas as pd
4
5
from delphi_utils import GeoMapper
5
6
from .constants import METRICS , COMBINED_METRIC
6
7
7
8
gmpr = GeoMapper ()
9
+
8
10
def generate_transition_matrix (geo_res ):
9
11
"""
10
- Generate transition matrix from county to msa/hrr
12
+ Generate transition matrix from county to msa/hrr.
11
13
12
14
Parameters
13
15
----------
Original file line number Diff line number Diff line change
1
+ """Retrieve data and wrangle into appropriate format."""
1
2
# -*- coding: utf-8 -*-
2
3
import re
3
4
8
9
9
10
def get_geo_id (region_code ):
10
11
"""
12
+ Extract fips code from region code.
13
+
11
14
There are region code in the format of "US-state" and "US-state-fips". In
12
15
county level report, we only consider rows with fips info provided.
13
16
"""
@@ -19,8 +22,7 @@ def get_geo_id(region_code):
19
22
20
23
def preprocess (df , level ):
21
24
"""
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.
24
26
25
27
The output dataset has:
26
28
@@ -90,7 +92,9 @@ def preprocess(df, level):
90
92
return df
91
93
92
94
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
94
98
conforms it into a dataset as described in preprocess function.
95
99
96
100
Note that we retrieve state level data from "2020_US_daily_symptoms_dataset.csv"
Original file line number Diff line number Diff line change 17
17
18
18
19
19
def run_module ():
20
-
20
+ """Run Google Symptoms module."""
21
21
params = read_params ()
22
22
export_start_date = datetime .strptime (params ["export_start_date" ], "%Y-%m-%d" )
23
23
export_dir = params ["export_dir" ]
Original file line number Diff line number Diff line change
1
+ """Functions for smoothing signals."""
1
2
# -*- coding: utf-8 -*-
2
3
import numpy as np
3
4
4
5
def identity (x ):
5
- ''' Trivial "smoother" that does no smoothing.
6
+ """ Trivial "smoother" that does no smoothing.
6
7
7
8
Parameters
8
9
----------
@@ -13,11 +14,11 @@ def identity(x):
13
14
-------
14
15
np.ndarray:
15
16
Same as x
16
- '''
17
+ """
17
18
return x
18
19
19
20
def kday_moving_average (x , k ):
20
- ''' Compute k-day moving average on x.
21
+ """ Compute k-day moving average on x.
21
22
22
23
Parameters
23
24
----------
@@ -28,7 +29,7 @@ def kday_moving_average(x, k):
28
29
-------
29
30
np.ndarray:
30
31
k-day moving average. The first k-1 entries are np.nan.
31
- '''
32
+ """
32
33
if not isinstance (k , int ):
33
34
raise ValueError ('k must be int.' )
34
35
# temp = np.append(np.zeros(k - 1), x)
You can’t perform that action at this time.
0 commit comments