diff --git a/google_symptoms/Makefile b/google_symptoms/Makefile index 56a71a88c..968732f99 100644 --- a/google_symptoms/Makefile +++ b/google_symptoms/Makefile @@ -13,7 +13,8 @@ install: venv lint: . env/bin/activate; \ - pylint $(dir) + pylint $(dir); \ + pydocstyle $(dir) test: . env/bin/activate ;\ diff --git a/google_symptoms/delphi_google_symptoms/__init__.py b/google_symptoms/delphi_google_symptoms/__init__.py index c28e7caca..75e3113b3 100644 --- a/google_symptoms/delphi_google_symptoms/__init__.py +++ b/google_symptoms/delphi_google_symptoms/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -"""Module to pull and clean indicators from the Google Research's Open - COVID-19 Data project. +"""Module to pull and clean indicators from the Google Research's Open COVID-19 Data project. + This file defines the functions that are made public by the module. As the module is intended to be executed though the main method, these are primarily for testing. diff --git a/google_symptoms/delphi_google_symptoms/constants.py b/google_symptoms/delphi_google_symptoms/constants.py index 48ef08f2e..c17cb91a4 100644 --- a/google_symptoms/delphi_google_symptoms/constants.py +++ b/google_symptoms/delphi_google_symptoms/constants.py @@ -1,4 +1,4 @@ -"""Registry for constants""" +"""Registry for constants.""" from functools import partial from datetime import timedelta diff --git a/google_symptoms/delphi_google_symptoms/geo.py b/google_symptoms/delphi_google_symptoms/geo.py index 0390a2cfa..1af3f3ce7 100644 --- a/google_symptoms/delphi_google_symptoms/geo.py +++ b/google_symptoms/delphi_google_symptoms/geo.py @@ -1,3 +1,4 @@ +"""Functions for mapping between geo regions.""" # -*- coding: utf-8 -*- import numpy as np import pandas as pd @@ -5,9 +6,10 @@ from .constants import METRICS, COMBINED_METRIC gmpr = GeoMapper() + def generate_transition_matrix(geo_res): """ - Generate transition matrix from county to msa/hrr + Generate transition matrix from county to msa/hrr. Parameters ---------- diff --git a/google_symptoms/delphi_google_symptoms/pull.py b/google_symptoms/delphi_google_symptoms/pull.py index 0667dc568..accd8613b 100644 --- a/google_symptoms/delphi_google_symptoms/pull.py +++ b/google_symptoms/delphi_google_symptoms/pull.py @@ -1,3 +1,4 @@ +"""Retrieve data and wrangle into appropriate format.""" # -*- coding: utf-8 -*- import re @@ -8,6 +9,8 @@ def get_geo_id(region_code): """ + Extract fips code from region code. + There are region code in the format of "US-state" and "US-state-fips". In county level report, we only consider rows with fips info provided. """ @@ -19,8 +22,7 @@ def get_geo_id(region_code): def preprocess(df, level): """ - Conforms the pulled data from Google COVID-19 Search Trends symptoms - data into a dataset + Conforms the pulled data from Google COVID-19 Search Trends symptoms data into a dataset. The output dataset has: @@ -90,7 +92,9 @@ def preprocess(df, level): return df def pull_gs_data(base_url): - """Pulls the latest Google COVID-19 Search Trends symptoms dataset, and + """Pull latest dataset and transform it into the appropriate format. + + Pull the latest Google COVID-19 Search Trends symptoms dataset, and conforms it into a dataset as described in preprocess function. Note that we retrieve state level data from "2020_US_daily_symptoms_dataset.csv" diff --git a/google_symptoms/delphi_google_symptoms/run.py b/google_symptoms/delphi_google_symptoms/run.py index 09949259b..2d2737b7c 100644 --- a/google_symptoms/delphi_google_symptoms/run.py +++ b/google_symptoms/delphi_google_symptoms/run.py @@ -17,7 +17,7 @@ def run_module(): - + """Run Google Symptoms module.""" params = read_params() export_start_date = datetime.strptime(params["export_start_date"], "%Y-%m-%d") export_dir = params["export_dir"] diff --git a/google_symptoms/delphi_google_symptoms/smooth.py b/google_symptoms/delphi_google_symptoms/smooth.py index a6c944fc2..f4e0c2911 100644 --- a/google_symptoms/delphi_google_symptoms/smooth.py +++ b/google_symptoms/delphi_google_symptoms/smooth.py @@ -1,8 +1,9 @@ +"""Functions for smoothing signals.""" # -*- coding: utf-8 -*- import numpy as np def identity(x): - '''Trivial "smoother" that does no smoothing. + """Trivial "smoother" that does no smoothing. Parameters ---------- @@ -13,11 +14,11 @@ def identity(x): ------- np.ndarray: Same as x - ''' + """ return x def kday_moving_average(x, k): - '''Compute k-day moving average on x. + """Compute k-day moving average on x. Parameters ---------- @@ -28,7 +29,7 @@ def kday_moving_average(x, k): ------- np.ndarray: k-day moving average. The first k-1 entries are np.nan. - ''' + """ if not isinstance(k, int): raise ValueError('k must be int.') # temp = np.append(np.zeros(k - 1), x)