Skip to content

Commit 756d5c4

Browse files
authored
Merge pull request #373 from cmu-delphi/sg-docs
Update safegraph docstrings to pass pydocstyle
2 parents b11148e + 67496b3 commit 756d5c4

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

safegraph/delphi_safegraph/process.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@
1818

1919

2020
def validate(df):
21-
"""Confirms that a data frame has only one date."""
21+
"""Confirm that a data frame has only one date."""
2222
timestamps = df['date_range_start'].apply(date_from_timestamp)
2323
assert len(timestamps.unique()) == 1
2424

2525

2626
def date_from_timestamp(timestamp) -> datetime.date:
27-
"""Extracts the date from a timestamp beginning with {YYYY}-{MM}-{DD}T."""
27+
"""Extract the date from a timestamp beginning with {YYYY}-{MM}-{DD}T."""
2828
return datetime.date.fromisoformat(timestamp.split('T')[0])
2929

3030

3131
def files_in_past_week(current_filename) -> List[str]:
32-
"""Constructs file paths from previous 6 days.
32+
"""Construct file paths from previous 6 days.
33+
3334
Parameters
3435
----------
3536
current_filename: str
@@ -51,12 +52,13 @@ def files_in_past_week(current_filename) -> List[str]:
5152

5253

5354
def add_suffix(signals, suffix):
54-
"""Adds `suffix` to every element of `signals`."""
55+
"""Add `suffix` to every element of `signals`."""
5556
return [s + suffix for s in signals]
5657

5758

5859
def construct_signals(cbg_df, signal_names):
5960
"""Construct Census-block level signals.
61+
6062
In its current form, we prepare the following signals in addition to those
6163
already available in raw form from Safegraph:
6264
- completely_home_prop, defined as:
@@ -80,7 +82,6 @@ def construct_signals(cbg_df, signal_names):
8082
Dataframe with columns: timestamp, county_fips, and
8183
{each signal described above}.
8284
"""
83-
8485
# Preparation
8586
cbg_df['county_fips'] = (cbg_df['origin_census_block_group'] // MOD).apply(
8687
lambda x: f'{int(x):05d}')
@@ -105,6 +106,7 @@ def construct_signals(cbg_df, signal_names):
105106

106107
def aggregate(df, signal_names, geo_resolution='county'):
107108
"""Aggregate signals to appropriate resolution and produce standard errors.
109+
108110
Parameters
109111
----------
110112
df: pd.DataFrame
@@ -156,9 +158,10 @@ def process_window(df_list: List[pd.DataFrame],
156158
signal_names: List[str],
157159
geo_resolutions: List[str],
158160
export_dir: str):
159-
"""Processes a list of input census block group-level data frames as a
160-
single data set and exports it. Assumes each data frame has _only_ one
161-
date of data.
161+
"""Process a list of input census block group-level data frames as a single data set and export.
162+
163+
Assumes each data frame has _only_ one date of data.
164+
162165
Parameters
163166
----------
164167
cbg_df: pd.DataFrame
@@ -200,8 +203,8 @@ def process(filenames: List[str],
200203
wip_signal,
201204
geo_resolutions: List[str],
202205
export_dir: str):
203-
"""Creates and exports signals corresponding both to a single day as well
204-
as averaged over the previous week.
206+
"""Create and exports signals corresponding both single day and averaged over the previous week.
207+
205208
Parameters
206209
----------
207210
current_filename: List[str]

safegraph/delphi_safegraph/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Functions to call when running the function.
2+
23
This module should contain a function called `run_module`, that is executed
34
when the module is run with `python -m MODULE_NAME`.
45
"""
@@ -14,7 +15,7 @@
1415

1516

1617
def run_module():
17-
"""Creates the Safegraph indicator."""
18+
"""Create the Safegraph indicator."""
1819
params = read_params()
1920

2021
# Place to write output files.

0 commit comments

Comments
 (0)