Vivarium Interactive Tools
This module provides an interface for interactive simulation usage. The main
part is the InteractiveContext
, a sub-class of the main simulation
object in vivarium
that has been extended to include convenience
methods for running and exploring the simulation in an interactive setting.
See the associated tutorials for running and exploring for more information.
- class vivarium.interface.interactive.InteractiveContext(*args, setup=True, **kwargs)[source]
A simulation context with helper methods for running simulations interactively.
- Parameters:
args (Any)
setup (bool)
kwargs (Any)
- run_for(duration, with_logging=True)[source]
Run the simulation for the given time duration.
- Return type:
- Parameters:
- Returns:
The number of steps the simulation took.
- run_until(end_time, with_logging=True)[source]
Run the simulation until the provided end time.
- Return type:
- Parameters:
end_time (Timestamp | datetime | int) – The time to run the simulation until. The simulation will run until its clock is greater than or equal to the provided end time. Must be compatible with the simulation clock’s step size (usually a pandas.Timestamp)
with_logging (bool) – Whether or not to log the simulation steps. Only works in an ipython environment.
- Returns:
The number of steps the simulation took.
- take_steps(number_of_steps=1, step_size=None, with_logging=True)[source]
Run the simulation for the given number of steps.
- Return type:
- Parameters:
number_of_steps (int) – The number of steps to take.
step_size (Timedelta | timedelta | int | None) – An optional size of step to take. Must be compatible with the simulation clock’s step size (usually a pandas.Timedelta).
with_logging (bool) – Whether or not to log the simulation steps. Only works in an ipython environment.
- get_listeners(event_type)[source]
Get all listeners of a particular type of event.
Available event types can be found by calling
InteractiveContext.list_events()
.
- get_emitter(event_type)[source]
Get the callable that emits the given type of events.
Available event types can be found by calling
InteractiveContext.list_events()
.
- list_components()[source]
Get a mapping of component names to components currently in the simulation.
- get_component(name)[source]
Get the component in the simulation that has
name
, if present. Names are guaranteed to be unique.