Skip to content

Commit

Permalink
remove instances of spread draws
Browse files Browse the repository at this point in the history
  • Loading branch information
AFg6K7h4fhy2 committed Sep 13, 2024
1 parent f0ff527 commit 4183ccc
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 82 deletions.
2 changes: 0 additions & 2 deletions docs/source/tutorials/day_of_the_week.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ As a result, we can see the posterior distribution of our novel day-of-the-week
out = hosp_model_dow.plot_posterior(
var="dayofweek_effect_raw", ylab="Day of the Week Effect", samples=500
)
sp = hosp_model_dow.spread_draws(["dayofweek_effect"])
```

The new model with the day-of-the-week effect can be compared to the previous model without the effect. Finally, let's reproduce the figure without the day-of-the-week effect, and then plot the new model with the effect:
Expand Down
35 changes: 0 additions & 35 deletions test/test_model_basic_renewal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
import numpyro
import numpyro.distributions as dist
import polars as pl
import pytest

from pyrenew.deterministic import DeterministicPMF, NullObservation
Expand Down Expand Up @@ -157,17 +156,6 @@ def test_model_basicrenewal_no_obs_model():
data_observed_infections=model0_samp.latent_infections,
)

inf = model0.spread_draws(["all_latent_infections"])
inf_mean = (
inf.group_by("draw")
.agg(pl.col("all_latent_infections").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500


def test_model_basicrenewal_with_obs_model():
"""
Expand Down Expand Up @@ -215,17 +203,6 @@ def test_model_basicrenewal_with_obs_model():
data_observed_infections=model1_samp.observed_infections,
)

inf = model1.spread_draws(["all_latent_infections"])
inf_mean = (
inf.group_by("draw")
.agg(pl.col("all_latent_infections").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500


def test_model_basicrenewal_padding() -> None: # numpydoc ignore=GL08
gen_int = DeterministicPMF(
Expand Down Expand Up @@ -264,15 +241,3 @@ def test_model_basicrenewal_padding() -> None: # numpydoc ignore=GL08
data_observed_infections=model1_samp.observed_infections,
padding=pad_size,
)

inf = model1.spread_draws(["all_latent_infections"])

inf_mean = (
inf.group_by("draw")
.agg(pl.col("all_latent_infections").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500
45 changes: 0 additions & 45 deletions test/test_model_hosp_admissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import numpy as np
import numpyro
import numpyro.distributions as dist
import polars as pl
import pytest

from pyrenew.deterministic import (
Expand Down Expand Up @@ -255,17 +254,6 @@ def test_model_hosp_no_obs_model():
data_observed_hosp_admissions=model0_samp.latent_hosp_admissions,
)

inf = model0.spread_draws(["latent_hospital_admissions"])
inf_mean = (
inf.group_by("draw")
.agg(pl.col("latent_hospital_admissions").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500


def test_model_hosp_with_obs_model():
"""
Expand Down Expand Up @@ -342,17 +330,6 @@ def test_model_hosp_with_obs_model():
data_observed_hosp_admissions=model1_samp.observed_hosp_admissions,
)

inf = model1.spread_draws(["latent_hospital_admissions"])
inf_mean = (
inf.group_by("draw")
.agg(pl.col("latent_hospital_admissions").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500


def test_model_hosp_with_obs_model_weekday_phosp_2():
"""
Expand Down Expand Up @@ -436,17 +413,6 @@ def test_model_hosp_with_obs_model_weekday_phosp_2():
data_observed_hosp_admissions=model1_samp.observed_hosp_admissions,
)

inf = model1.spread_draws(["latent_hospital_admissions"])
inf_mean = (
inf.group_by("draw")
.agg(pl.col("latent_hospital_admissions").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500


def test_model_hosp_with_obs_model_weekday_phosp():
"""
Expand Down Expand Up @@ -558,14 +524,3 @@ def test_model_hosp_with_obs_model_weekday_phosp():
data_observed_hosp_admissions=model1_samp.observed_hosp_admissions,
padding=pad_size,
)

inf = model1.spread_draws(["latent_hospital_admissions"])
inf_mean = (
inf.group_by("draw")
.agg(pl.col("latent_hospital_admissions").mean())
.sort(pl.col("draw"))
)

# For now the assertion is only about the expected number of rows
# It should be about the MCMC inference.
assert inf_mean.to_numpy().shape[0] == 500

0 comments on commit 4183ccc

Please sign in to comment.