Skip to content

Update combo cases docstrings to pass pydocstyle #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Registry for signal names, geo types and other constants"""
"""Registry for signal names, geo types and other constants."""
METRICS = [
"confirmed",
"deaths",
Expand Down
19 changes: 10 additions & 9 deletions combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
"""Functions to call when running the function.

This module should contain a function called `run_module`, that is executed when
the module is run with `python -m delphi_combo_cases_and_deaths`.
This module produces a combined signal for jhu-csse and usa-facts. This signal
Expand All @@ -26,6 +27,8 @@ def check_none_data_frame(data_frame, label, date_range):

def maybe_append(df1, df2):
"""
Append dataframes if available, otherwise return non-None one.

If both data frames are available, append them and return. Otherwise, return
whichever frame is not None.
"""
Expand All @@ -41,9 +44,7 @@ def maybe_append(df1, df2):
"stderr": "se",
"sample_size": "sample_size"}
def combine_usafacts_and_jhu(signal, geo, date_range, fetcher=covidcast.signal):
"""
Add rows for PR from JHU signals to USA-FACTS signals
"""
"""Add rows for PR from JHU signals to USA-FACTS signals."""
print("Fetching usa-facts...")
usafacts_df = fetcher("usa-facts", signal, date_range[0], date_range[1], geo)
print("Fetching jhu-csse...")
Expand Down Expand Up @@ -74,7 +75,9 @@ def combine_usafacts_and_jhu(signal, geo, date_range, fetcher=covidcast.signal):
return combined_df

def extend_raw_date_range(params, sensor_name):
"""A complete issue includes smoothed signals as well as all raw data
"""Extend the date range of the raw data backwards by 7 days.

A complete issue includes smoothed signals as well as all raw data
that contributed to the smoothed values, so that it's possible to use
the raw values in the API to reconstruct the smoothed signal at will.
The smoother we're currently using incorporates the previous 7
Expand All @@ -99,17 +102,15 @@ def next_missing_day(source, signals):
return day

def sensor_signal(metric, sensor, smoother):
"""Generate the signal name for a particular configuration"""
"""Generate the signal name for a particular configuration."""
if smoother == "7dav":
sensor_name = "_".join([smoother, sensor])
else:
sensor_name = sensor
return sensor_name, "_".join([metric, sensor_name])

def configure(variants):
"""
Validate params file and set date range.
"""
"""Validate params file and set date range."""
params = read_params()
params['export_start_date'] = date(*params['export_start_date'])
yesterday = date.today() - timedelta(days=1)
Expand Down Expand Up @@ -153,7 +154,7 @@ def configure(variants):


def run_module():
"""Produce a combined cases and deaths signal using data from JHU and USA Facts"""
"""Produce a combined cases and deaths signal using data from JHU and USA Facts."""
variants = [tuple((metric, geo_res)+sensor_signal(metric, sensor, smoother))
for (metric, geo_res, sensor, smoother) in
product(METRICS, GEO_RESOLUTIONS, SENSORS, SMOOTH_TYPES)]
Expand Down