SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] Comparing pdf output in tests

From: John H. <jd...@gm...> - 2009年09月23日 18:13:10
On Wed, Sep 23, 2009 at 12:56 PM, Andrew Straw <str...@as...> wrote:
> John Hunter wrote:
>> On Wed, Sep 23, 2009 at 12:42 PM, Andrew Straw <str...@as...> wrote:
>>
>>
>>> 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.
>>>
>>
>> Why not have the decorator pass the extension in to the test funcs --
>> agg can print to pdf, ps, svg and png
>>
> I'm not sure what you're suggesting. Presumably if we're driving agg OK
> to draw .png, it will also draw .pdf OK (or does it have a pdf vector
> backend independent of the MPL pdf backend that we want to test separately?)
No, it doesn't have a separate backend, but the backend_agg figure
canvas savefig method knows how to create FigureCanvasPDF etc to use
that backend to write the file w/o having to switch the default
backend with all the attendant hassles. So if you are using *Agg, and
do
 savefig(somefile.pdf)
agg will load the native pdf backend and use it. So I was envisioning
def test_something(ext):
 make_plot
 fig.savefig('myfile.%s'%ext)
and having the decorator pass in the extensions it wants one-by-one
JDH

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /