Loop#

class Loop(sim)[source]#

Bases: object

Base class for integration loop

Methods

init()[source]#

Parse the sim into the integration plan

collect_funcs()[source]#

Collect all the callable functions (methods) that comprise the step

collect_abs_tvecs()[source]#

Collect numerical time arrays for each module

make_plan()[source]#

Combine the module ordering and the time vectors into the integration plan

store_time()[source]#

Store the current time in as high resolution as possible

run_one_step()[source]#

Take a single step, i.e. call a single function; only used for debugging purposes.

Compare sim.run_one_step(), which runs a full timestep (which involves multiple function calls).

run(until=None, verbose=None)[source]#

Actually run the integration loop; usually called by sim.run()

manual_reset()[source]#

Reset the loop to run again. Note, does not reset sim quantities so should only be used for debugging.

to_df()[source]#

Return a user-friendly version of the plan, omitting object columns

plot(simplify=False, fig_kw=None, plot_kw=None, scatter_kw=None)[source]#

Plot a diagram of all the events

Parameters:
  • simplify (bool) – if True, skip update_results and finish_step events, which are automatically applied

  • fig_kw (dict) – passed to plt.figure()

  • plot_kw (dict) – passed to plt.plot()

  • scatter_kw (dict) – passed to plt.scatter()

plot_cpu(bytime=True, fig_kw=None, bar_kw=None)[source]#

Plot the CPU time spent on each event; visualization of Loop.cpu_df.

Parameters:
  • bytime (bool) – if True, order events by total time rather than actual order

  • fig_kw (dict) – passed to plt.figure()

  • plot_kw (dict) – passed to plt.bar()