Skip to content

Commit 60b155b

Browse files
pass geo_mapper as argument in pop_prop function
1 parent 8088785 commit 60b155b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

hhs_hosp/delphi_hhs/run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def run_module(params):
104104
"state_code",
105105
from_col="state")
106106
if sensor==POP_PROP:
107-
df=pop_proportion(df)
107+
df=pop_proportion(df,geo_mapper)
108108
df = make_geo(df, geo, geo_mapper)
109109
df = smooth_values(df, smoother[0])
110110
if df.empty:
@@ -140,9 +140,8 @@ def smooth_values(df, smoother):
140140
)
141141
return df
142142

143-
def pop_proportion(df):
143+
def pop_proportion(df,geo_mapper):
144144
"""Get the population-proportionate variants as the dataframe val."""
145-
geo_mapper = GeoMapper()
146145
pop_val=geo_mapper.add_population_column(df, "state_code")
147146
df["val"]=df["val"]/pop_val["population"]*100000
148147
pop_val.drop("population", axis=1, inplace=True)

hhs_hosp/tests/test_run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ def test_make_signal():
7979
make_signal(data, "zig")
8080

8181
def test_pop_proportion():
82+
geo_mapper = GeoMapper()
8283
test_df = pd.DataFrame({
8384
'state': ['PA'],
8485
'state_code':[42],
8586
'timestamp': [datetime(year=2020, month=1, day=1)],
8687
'val': [15.],})
8788
pd.testing.assert_frame_equal(
88-
pop_proportion(test_df),
89+
pop_proportion(test_df,geo_mapper),
8990
pd.DataFrame({
9091
'state': ['PA'],
9192
'state_code':[42],

0 commit comments

Comments
 (0)