You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we are testing the .plot() methods of our data classes, just by calling .plot() and in some cases by calling mpl_savefig_check() after. When multiple plot methods are executed in one test session, the plots are drawn on the same axes, because we typically call plt.gca() to get the current axes object. This leads to unexpected warnings and funny plots such as:
I discussed with @cdeil we should introduce a check_mpl() context manager that deletes current axes objects in __enter__ and calls the savefig check in __exit__. All places in Gammapy where we test plot methods should the be adapted accordingly.
The text was updated successfully, but these errors were encountered:
context manager that deletes current axes objects in enter and calls the savefig check in exit
I think we should do plt.figure to make a new figure in __enter__ instead of deleting existing things, and close it in __exit__. See example and discussion in matplotlib/matplotlib#5218
All places in Gammapy where we test plot methods should the be adapted accordingly.
You can get a complete list of all existing plot test with:
$ ack requires_dependency | grep matplotlib
Of course it would be nice if you could also check somehow if we have completely untested plot methods left; this is a good start:
$ ack def | grep plot | egrep -v test
Although that also comes out of missing test coverage, so we'll get to that later anyways in a systematic fashion.
Currently we are testing the
.plot()
methods of our data classes, just by calling.plot()
and in some cases by callingmpl_savefig_check()
after. When multiple plot methods are executed in one test session, the plots are drawn on the same axes, because we typically callplt.gca()
to get the current axes object. This leads to unexpected warnings andfunny
plots such as:I discussed with @cdeil we should introduce a
check_mpl()
context manager that deletes current axes objects in__enter__
and calls the savefig check in__exit__
. All places in Gammapy where we test plot methods should the be adapted accordingly.The text was updated successfully, but these errors were encountered: