Note

You are not reading the stable version of Gammapy documentation.
Access the latest stable version v1.3 or the list of Gammapy releases.

mpl_plot_check

gammapy.utils.testing.mpl_plot_check()[source]

Matplotlib plotting test context manager.

It create a new figure on __enter__ and calls savefig for the current figure in __exit__. This will trigger a render of the Figure, which can sometimes raise errors if there is a problem.

This is writing to an in-memory byte buffer, i.e. is faster than writing to disk.