Helper Functions#

squap.display_fps(
update_speed=0.2,
get_fps=False,
optimized=False,
ax=None,
)[source]#

Display frames per second (fps) at the top of the plot widget.

Parameters:
  • update_speed (float) – The update speed for fps calculation. Defaults to 0.2 seconds.

  • get_fps (bool) – Whether to store the fps. If set to True, the fps will be saved to var.fps every time it is updated. Defaults to False.

  • optimized (bool) – Whether to use an optimized calculation method. If set to True, it is a bit quicker, but less consistent for variable fps. Defaults to False.

  • ax (SubplotWidget, optional) – Which window to set the title to the fps. Defaults to top-left.

Returns:

Function that is needed to update the fps. If the program is run using squap.show(), this is handled automatically, but when you use squap.show_window(), it needs to be run with squap.refresh(), either manually or by calling squap.refresh(call_update_funcs=True).

Return type:

callable

Raises:

NotImplementedError – If the function is called in 3D plot style, which is not supported yet.

squap.benchmark(n_frames=None, duration=None)[source]#

Run the program until it is closed and then report the total frames and fps.

If n_frames or duration are specified, the program will quit when either has passed.

Parameters:
  • n_frames (int, optional) – Number of frames to run the program for.

  • duration (float, optional) – Total time to run the program for in seconds.