Andrew Straw <straw...@astraw.com> writes: > Jouni - I don't think this would be hard to add, but I'm swamped at > work. If this is an itch you'd like to scratch, feel free to hack away > on the image_comparison() function in > lib/matplotlib/testing/decorators.py -- it's a pretty straightforward > piece of code.
Changing that is probably easy enough, but how should the overall code path look? I was planning to switch backends in matplotlib.test after it runs the Agg tests, so that the same test cases could be used to produce pdf files (that's why they save files without extensions, right?) but this seems to be impossible. The matplotlib.use function is a no-op if matplotlib.backends has been imported, regardless of the warn argument. For example, the following code produces two png files: #!/usr/bin/env python import matplotlib matplotlib.use('agg') from matplotlib import pyplot pyplot.plot([3,1,4,1]) pyplot.savefig('foo1') pyplot.switch_backend('pdf') pyplot.plot([5,9,2,6]) pyplot.savefig('foo2') If you interchange the 'agg' and 'pdf' strings, you get two pdf files. It looks like the following change to matplotlib/__init__.py would fix this, but I'm a little doubtful since maybe there was a good reason to make it like it is: --- __init__.py (revision 7815) +++ __init__.py (working copy) @@ -822,8 +822,8 @@ make the backend switch work (in some cases, eg pure image backends) so one can set warn=False to supporess the warnings """ - if 'matplotlib.backends' in sys.modules: - if warn: warnings.warn(_use_error_msg) + if 'matplotlib.backends' in sys.modules and warn: + warnings.warn(_use_error_msg) return arg = arg.lower() if arg.startswith('module://'): -- Jouni K. Seppänen http://www.iki.fi/jks ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel