sim
Define core Sim classes
Classes
| Name | Description |
|---|---|
| AlreadyRunError | This error is raised if a simulation is run in such a way that no timesteps |
AlreadyRunError
sim.AlreadyRunError()This error is raised if a simulation is run in such a way that no timesteps will be taken. This error is a distinct type so that it can be safely caught and ignored if required, but it is anticipated that most of the time, calling Sim.run and not taking any timesteps, would be an inadvertent error.
Functions
| Name | Description |
|---|---|
| diff_sims | Compute the difference of the summaries of two simulations, and print any |
diff_sims
sim.diff_sims(
sim1,
sim2,
skip_key_diffs=False,
skip=None,
full=False,
output=False,
die=False,
)Compute the difference of the summaries of two simulations, and print any values which differ.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| sim1 | sim / dict | either a simulation object or the sim.summary dictionary | required |
| sim2 | sim / dict | ditto | required |
| skip_key_diffs | bool | whether to skip keys that don’t match between sims | False |
| skip | list | a list of values to skip | None |
| full | bool | whether to use the full summary (else, brief) | False |
| output | bool | whether to return the output as a string (otherwise print) | False |
| die | bool | whether to raise an exception if the sims don’t match | False |
| require_run | bool | require that the simulations have been run | required |
Example::
s1 = hpv.Sim(rand_seed=1).run()
s2 = hpv.Sim(rand_seed=2).run()
hpv.diff_sims(s1, s2)