Stream: helpdesk (published)

Topic: ✔ How to test when there are figures?


view this post on Zulip Davi Sales Barreira (Mar 24 2024 at 14:32):

I'm develop a package that produces visualizations. Most of my (informal) testing has been using a notebook to generate visualizations, and then constantly checking if things are still in order.
I was wondering if there is any Julia package (or testing design strategy) for such situation. Perhaps comparing the SVG output to see if it matches (this seems highly innapropriate)?

view this post on Zulip Brian Chen (Mar 24 2024 at 15:26):

Depending on how much run-to-run variance you expect in these visualizations, https://github.com/JuliaTesting/ReferenceTests.jl may help

view this post on Zulip jar (Mar 24 2024 at 18:58):

Can you explain what you don't like about comparing the svg output? Which aspects of a figure do you expect to be preserved across runs?

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 11:27):

If the new svg has an extra whitespace that does not affect the image, then the test would fail.

view this post on Zulip cormullion (Mar 25 2024 at 13:49):

Although , changes in margins and white space could be considered to be significant changes… I don’t think there’s an easy way to get the bounding box of visible graphics from the SVG - lots of transforms to analyse…. Although you could convert it to PNG and look for borders :thinking:

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 13:50):

I meant in the SVG file. Like <circle cx = 1> and <circle cx=1>.

view this post on Zulip Sebastian Pfitzner (Mar 25 2024 at 13:50):

you can parse the xml and compare that

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 13:51):

cormullion said:

Although , changes in margins and white space could be considered to be significant changes… I don’t think there’s an easy way to get the bounding box of visible graphics from the SVG - lots of transforms to analyse…. Although you could convert it to PNG and look for borders :thinking:

Yeah, the closer I got to was to turn it into a png, and define a distance function over the matrices in order to declare if they are similar enough.

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 13:52):

Sebastian Pfitzner said:

you can parse the xml and compare that

wouldn't it still suffer the same "white space" issue?

view this post on Zulip Sebastian Pfitzner (Mar 25 2024 at 13:52):

Your two examples should parse the same.

view this post on Zulip Sebastian Pfitzner (Mar 25 2024 at 13:53):

But you'll still run into issues if something in your stack changes and svgs get generated differently without a visible change

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 13:54):

Sebastian Pfitzner said:

Your two examples should parse the same.

I mean, if I have something like <circle ... style = {fill=nothing, stroke=red}> and <circle ... style = {stroke=red}> I think I'd again get an error.... I can think of other similar "differences" that are not actually "important".

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 13:54):

Sebastian Pfitzner said:

But you'll still run into issues if something in your stack changes and svgs get generated differently without a visible change

Yeah, that is the issue here. I actually want to compare the images, not the actual svg. At least, not in these tests I'm writing.

view this post on Zulip Davi Sales Barreira (Mar 25 2024 at 13:55):

I think raster images seems to be the way to go.
Thanks for the inputs.

view this post on Zulip Notification Bot (Mar 25 2024 at 17:08):

Davi Sales Barreira has marked this topic as resolved.

view this post on Zulip Andrés Riedemann (Mar 31 2024 at 07:19):

What about this pkg https://github.com/JuliaPlots/VisualRegressionTests.jl ?


Last updated: Nov 22 2024 at 04:41 UTC