Skip to content

Commit

Permalink
Ensure determinacy in the setup of a simulation. (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe authored May 21, 2021
1 parent c590e56 commit f2c4564
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ all releases are available on `Anaconda.org
- :gh:`126` enhances the plot for the channel of infections. The displayed numbers can
be shares among all infected, among all individuals or seven days incidences per
100,000 people.
- :gh:`127` includes better parameters for time-variant sensitivity of rapid tests.
- :gh:`128` ensures determinacy in the setup of a simulation.


0.0.7 - 2021-05-12
Expand Down
4 changes: 2 additions & 2 deletions src/sid/countdowns.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"""

COUNTDOWNS_WITHOUT_DRAWS = ("cd_received_rapid_test", "cd_ever_infected")
COUNTDOWNS_WITHOUT_DRAWS = ("cd_ever_infected", "cd_received_rapid_test")
"""Tuple[str]: Countdowns which do not have draws."""

COUNTDOWNS_WITH_DRAWS = tuple(set(COUNTDOWNS) - set(COUNTDOWNS_WITHOUT_DRAWS))
COUNTDOWNS_WITH_DRAWS = tuple(sorted(set(COUNTDOWNS) - set(COUNTDOWNS_WITHOUT_DRAWS)))
"""Tuple[str]: Countdowns whose length is a random variable."""
8 changes: 6 additions & 2 deletions src/sid/initial_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ def sample_initial_distribution_of_infections_and_immunity(
)

spread_out_virus_strains = _sample_factorized_virus_strains_for_infections(
spread_out_infections,
initial_conditions["virus_shares"],
spread_out_infections=spread_out_infections,
virus_shares=initial_conditions["virus_shares"],
seed=next(seed),
)

else:
Expand Down Expand Up @@ -418,8 +419,11 @@ def _spread_out_initial_infections(
def _sample_factorized_virus_strains_for_infections(
spread_out_infections: pd.DataFrame,
virus_shares: Dict[str, Any],
seed: int,
) -> pd.DataFrame:
"""Convert boolean infections to factorized virus strains."""
np.random.seed(seed)

spread_out_virus_strains = pd.DataFrame(
data=-1,
index=spread_out_infections.index,
Expand Down

0 comments on commit f2c4564

Please sign in to comment.