11# -*- coding: utf-8 -*-
22"""Functions to call when running the function.
3+
34This module should contain a function called `run_module`, that is executed when
45the module is run with `python -m delphi_combo_cases_and_deaths`.
56This module produces a combined signal for jhu-csse and usa-facts. This signal
@@ -26,6 +27,8 @@ def check_none_data_frame(data_frame, label, date_range):
2627
2728def maybe_append (df1 , df2 ):
2829 """
30+ Append dataframes if available, otherwise return non-None one.
31+
2932 If both data frames are available, append them and return. Otherwise, return
3033 whichever frame is not None.
3134 """
@@ -41,9 +44,7 @@ def maybe_append(df1, df2):
4144 "stderr" : "se" ,
4245 "sample_size" : "sample_size" }
4346def combine_usafacts_and_jhu (signal , geo , date_range , fetcher = covidcast .signal ):
44- """
45- Add rows for PR from JHU signals to USA-FACTS signals
46- """
47+ """Add rows for PR from JHU signals to USA-FACTS signals."""
4748 print ("Fetching usa-facts..." )
4849 usafacts_df = fetcher ("usa-facts" , signal , date_range [0 ], date_range [1 ], geo )
4950 print ("Fetching jhu-csse..." )
@@ -74,7 +75,9 @@ def combine_usafacts_and_jhu(signal, geo, date_range, fetcher=covidcast.signal):
7475 return combined_df
7576
7677def extend_raw_date_range (params , sensor_name ):
77- """A complete issue includes smoothed signals as well as all raw data
78+ """Extend the date range of the raw data backwards by 7 days.
79+
80+ A complete issue includes smoothed signals as well as all raw data
7881 that contributed to the smoothed values, so that it's possible to use
7982 the raw values in the API to reconstruct the smoothed signal at will.
8083 The smoother we're currently using incorporates the previous 7
@@ -99,17 +102,15 @@ def next_missing_day(source, signals):
99102 return day
100103
101104def sensor_signal (metric , sensor , smoother ):
102- """Generate the signal name for a particular configuration"""
105+ """Generate the signal name for a particular configuration. """
103106 if smoother == "7dav" :
104107 sensor_name = "_" .join ([smoother , sensor ])
105108 else :
106109 sensor_name = sensor
107110 return sensor_name , "_" .join ([metric , sensor_name ])
108111
109112def configure (variants ):
110- """
111- Validate params file and set date range.
112- """
113+ """Validate params file and set date range."""
113114 params = read_params ()
114115 params ['export_start_date' ] = date (* params ['export_start_date' ])
115116 yesterday = date .today () - timedelta (days = 1 )
@@ -153,7 +154,7 @@ def configure(variants):
153154
154155
155156def run_module ():
156- """Produce a combined cases and deaths signal using data from JHU and USA Facts"""
157+ """Produce a combined cases and deaths signal using data from JHU and USA Facts. """
157158 variants = [tuple ((metric , geo_res )+ sensor_signal (metric , sensor , smoother ))
158159 for (metric , geo_res , sensor , smoother ) in
159160 product (METRICS , GEO_RESOLUTIONS , SENSORS , SMOOTH_TYPES )]
0 commit comments