.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples_tutorials/example_scheduler.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_tutorials_example_scheduler.py: ================================================================================ Schedule tasks ================================================================================ Schedule task at different time interval. .. GENERATED FROM PYTHON SOURCE LINES 9-42 .. image-sg:: /auto_examples_tutorials/images/sphx_glr_example_scheduler_001.png :alt: example scheduler :srcset: /auto_examples_tutorials/images/sphx_glr_example_scheduler_001.png :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt import freshkiss3d as fk def run(scheduler, text): global yplot simutime = fk.SimuTime(final_time=5.) simutime.time_delta = 5./35. plt.plot([simutime.time,], [yplot,], 'bx') if scheduler.now(simutime): plt.plot([simutime.time], [yplot], 'ro') while not simutime.is_finished: simutime.increment() plt.plot([simutime.time,], [yplot,], 'bx') if scheduler.now(simutime): plt.plot([simutime.time], [yplot], 'ro') plt.text(0., yplot+0.25, text) yplot -= 1 yplot = 6 run(fk.schedules(time_delta=1.5), 'Every 1.5 seconds') run(fk.schedules(iteration_delta=5), 'Every 5 time iterations') run(fk.schedules(times=[0.5, 1., 4.5, 5.]), 'At given times') run(fk.schedules(iterations=[10, 12, 14, 16]), 'At given time iterations') run(fk.schedules(count=4), '4 equaly time-separated') run(fk.schedules(never=True), 'Never') run(fk.schedules(always=True), 'Always') plt.xlim(-0.5, 5.5) plt.ylim(-0.5, 7) plt.grid() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.375 seconds) .. _sphx_glr_download_auto_examples_tutorials_example_scheduler.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_scheduler.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_scheduler.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_