From 5515e6bac107e7fba067cd6a73e846047d8406af Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 26 Oct 2020 16:59:50 -0700 Subject: [PATCH] Update docs --- .../constants.py | 2 +- .../handle_wip_signal.py | 7 ++++--- .../delphi_combo_cases_and_deaths/run.py | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py index 2392366bb..36e2bc6a8 100644 --- a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py +++ b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/constants.py @@ -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", diff --git a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/handle_wip_signal.py b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/handle_wip_signal.py index 04d42b57c..2a7cf2f05 100644 --- a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/handle_wip_signal.py +++ b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/handle_wip_signal.py @@ -9,7 +9,8 @@ def add_prefix(signal_names, wip_signal, prefix="wip_"): - """Adds prefix to signal if there is a WIP signal + """Add prefix to signal if there is a WIP signal. + Parameters ---------- signal_names: List[str] @@ -25,7 +26,6 @@ def add_prefix(signal_names, wip_signal, prefix="wip_"): List of signal names wip/non wip signals for further computation """ - if wip_signal is True: return [prefix + signal for signal in signal_names] if isinstance(wip_signal, list): @@ -44,7 +44,8 @@ def add_prefix(signal_names, wip_signal, prefix="wip_"): def public_signal(signal_): - """Checks if the signal name is already public using COVIDcast + """Check if the signal name is already public using COVIDcast. + Parameters ---------- signal_ : str diff --git a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py index 8e8878e8c..75acc67f6 100755 --- a/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py +++ b/combo_cases_and_deaths/delphi_combo_cases_and_deaths/run.py @@ -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 @@ -27,6 +28,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. """ @@ -42,9 +45,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...") @@ -75,7 +76,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 @@ -100,7 +103,7 @@ 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: @@ -108,9 +111,7 @@ def sensor_signal(metric, sensor, smoother): 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) @@ -154,7 +155,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)]