From: Andrew S. <str...@as...> - 2009-09-23 17:43:10
|
Jouni K. Seppänen wrote: > John Hunter <jd...@gm...> writes: > > >>> pyplot.savefig('foo1') >>> >> Take a look at the pyplot "switch_backends" function. >> > > Yes, that function was on the next line after the part you quoted. :-) > It calls matplotlib.use with warn=False, but that function ends up doing > nothing. > > >> Alternatively, agg knows how to save pdf if given the extension, so we >> could wire up the testing to use a module level extension set >> somewhere which could be updated for each backend. This is probably >> safer and cleaner than switch_backends >> > > That sounds complicated. How about having the test cases call savefig > with all the relevant file formats? That doesn't look so nice if the > test cases end up with a big block of savefig calls, but it has the > advantage that there is no magic involved and it is very obvious what is > going on. > Sorry, I should have been more clear. I was thinking that the image_compare() decorator would call the test function multiple times, having switched the backend between invocations. Thus, the call to savefig() would continue not to explicitly set the extension. I've quickly modified the source to reflect my idea, but I haven't had a chance to flesh it out or test it. It should show the idea, though. See attached. -Andrew |