Skip to content

Commit

Permalink
Do not rescale seasonality. (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
janosg committed May 28, 2021
1 parent d745885 commit 3e311ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/sid/seasonality.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ def prepare_seasonality_factor(
"with 'dates' as index and seasonality factors as data."
)

# Make sure the highest multiplier is set to one so that random contacts only
# need to be reduced by the infection probability of the contact model.
for col in factor:
factor[col] = factor[col] / factor[col].max()
if not factor[col].between(0, 1).all():
raise ValueError(
"The seasonality factors need to lie in the interval [0, 1]."
)
factor = factor.astype(float)

for col in factor:
if not factor[col].between(0, 1).all():
raise ValueError(
"The seasonality factors need to lie in the interval [0, 1]."
)

return factor
4 changes: 2 additions & 2 deletions tests/test_seasonality.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def test_simulate_a_simple_model(params, initial_states, tmp_path):
index=pd.date_range("2020-01-01", periods=2),
data=1,
columns=["meet_two_people"],
),
).astype(float),
{"meet_two_people": {}},
),
pytest.param(
lambda params, dates, seed: pd.Series(index=dates, data=[1, 2, 3]),
lambda params, dates, seed: pd.Series(index=dates, data=[1 / 3, 2 / 3, 1]),
None,
pd.date_range("2020-01-01", periods=3),
does_not_raise(),
Expand Down

0 comments on commit 3e311ef

Please sign in to comment.