Timing and media tools#

The genesis.utils.tools module provides small helpers for timing loops and saving media, exposed under gs.utils.tools.

Timing#

class genesis.utils.tools.Timer(skip=False, level=0, qd_sync=False)[source]#
genesis.utils.tools.create_timer(name=None, new=False, level=0, qd_sync=False, skip_first_call=False)[source]#
class genesis.utils.tools.Rate(rate)[source]#

Fixed-frequency loop limiter: call sleep once per iteration to hold the loop at rate Hz.

Each wake-up is scheduled against an ideal clock advanced by exactly one period per tick, rather than from the actual (over-slept) wake time, so time.sleep overshoot does not accumulate and the average rate stays on target. When an iteration runs longer than one period the limiter does not sleep and resets its schedule from the current time, so a loop that cannot keep up simply runs as fast as it can without building a sleep debt to burn off afterwards.

class genesis.utils.tools.FPSTracker(n_envs, alpha=0.95, minimum_interval_seconds: float | None = 0.05)[source]#

Estimates and logs the achieved step rate over fixed wall-clock windows.

The per-window rate is the actual step count divided by the actual window duration (so it is phase-stable, unlike dividing a raw count by a smoothed time), then lightly EMA-smoothed for readability.

Media#

genesis.utils.tools.animate(imgs, filename=None, fps=60)[source]#

Create a video from a list of images.

Parameters:
  • imgs (list) – List of input images.

  • filename (str, optional) – Name of the output video file. If not provided, the name will default to the name of the script the process was launched from, with a timestamp and ‘.mp4’ extension.

genesis.utils.tools.save_img_arr(arr, filename='img.png')[source]#

See also#