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
@@ -27,6 +28,8 @@ def check_none_data_frame(data_frame, label, date_range):
2728
2829def maybe_append (df1 , df2 ):
2930 """
31+ Append dataframes if available, otherwise return non-None one.
32+
3033 If both data frames are available, append them and return. Otherwise, return
3134 whichever frame is not None.
3235 """
@@ -42,9 +45,7 @@ def maybe_append(df1, df2):
4245 "stderr" : "se" ,
4346 "sample_size" : "sample_size" }
4447def combine_usafacts_and_jhu (signal , geo , date_range , fetcher = covidcast .signal ):
45- """
46- Add rows for PR from JHU signals to USA-FACTS signals
47- """
48+ """Add rows for PR from JHU signals to USA-FACTS signals."""
4849 print ("Fetching usa-facts..." )
4950 usafacts_df = fetcher ("usa-facts" , signal , date_range [0 ], date_range [1 ], geo )
5051 print ("Fetching jhu-csse..." )
@@ -75,7 +76,9 @@ def combine_usafacts_and_jhu(signal, geo, date_range, fetcher=covidcast.signal):
7576 return combined_df
7677
7778def extend_raw_date_range (params , sensor_name ):
78- """A complete issue includes smoothed signals as well as all raw data
79+ """Extend the date range of the raw data backwards by 7 days.
80+
81+ A complete issue includes smoothed signals as well as all raw data
7982 that contributed to the smoothed values, so that it's possible to use
8083 the raw values in the API to reconstruct the smoothed signal at will.
8184 The smoother we're currently using incorporates the previous 7
@@ -100,17 +103,15 @@ def next_missing_day(source, signals):
100103 return day
101104
102105def sensor_signal (metric , sensor , smoother ):
103- """Generate the signal name for a particular configuration"""
106+ """Generate the signal name for a particular configuration. """
104107 if smoother == "7dav" :
105108 sensor_name = "_" .join ([smoother , sensor ])
106109 else :
107110 sensor_name = sensor
108111 return sensor_name , "_" .join ([metric , sensor_name ])
109112
110113def configure (variants ):
111- """
112- Validate params file and set date range.
113- """
114+ """Validate params file and set date range."""
114115 params = read_params ()
115116 params ['export_start_date' ] = date (* params ['export_start_date' ])
116117 yesterday = date .today () - timedelta (days = 1 )
@@ -154,7 +155,7 @@ def configure(variants):
154155
155156
156157def run_module ():
157- """Produce a combined cases and deaths signal using data from JHU and USA Facts"""
158+ """Produce a combined cases and deaths signal using data from JHU and USA Facts. """
158159 variants = [tuple ((metric , geo_res )+ sensor_signal (metric , sensor , smoother ))
159160 for (metric , geo_res , sensor , smoother ) in
160161 product (METRICS , GEO_RESOLUTIONS , SENSORS , SMOOTH_TYPES )]
0 commit comments