Fix example script
@@ -21,27 +21,31 @@ fig = sim.plot()
# Make and use a random population (including community transmission)
pars = cv.make_pars()
-pars['population'] = cv.Population.random(pars, n_random_contacts=20)
-sim = cv.Sim(pars=pars)
+population = cv.Population.random(pars, n_random_contacts=20)
+sim = cv.Sim(pars=pars, population=population)
sim.run()
fig = sim.plot()
# Add an intervention changing the overall beta
+pars = cv.make_pars()
+population = cv.Population.random(pars, n_random_contacts=20)
pars['interventions'] = cv.interventions.change_beta(25, 0.5)
-sim = cv.Sim(pars=pars)
+sim = cv.Sim(pars=pars, population=population)
sim.run()
fig = sim.plot()
# Change beta only for community contacts
-pars['interventions'] = cv.interventions.change_beta(25, 0.0, pars['population'].contact_layers['Community'])
-sim = cv.Sim(pars=pars)
+pars = cv.make_pars()
+population = cv.Population.random(pars, n_random_contacts=20)
+pars['interventions'] = cv.interventions.change_beta(25, 0.0, population.contact_layers['Community'])
+sim = cv.Sim(pars=pars, population=population)
sim.run()
fig = sim.plot()
# Run sim using synthpops with community transmission
if cv.requirements.available['synthpops']:
pars = cv.make_pars()
- pars['population'] = cv.Population.synthpops(pars, n_people=5000, n_random_contacts=20)
- sim = cv.Sim(pars=pars)
+ population = cv.Population.synthpops(pars, n_people=5000, n_random_contacts=20)
+ sim = cv.Sim(pars=pars, population=population)
sim.run()
fig = sim.plot()
