Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11784

Re: Regression Testing of Graphics: some questions

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Regression Testing of Graphics: some questions
Date 2012-09-17 04:28 +0000
Message-ID <k368tm$20l$1@smc.vnet.net> (permalink)
References <20120916072514.963746863@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Why use cut-and-paste?

graf := ListPlot[{1, 2, 2, 3},
   ImageSize -> Tiny];

previousResult = graf;

Head[previousResult]

Graphics

previousResult === graf

True

test[expr_, ansr_] := expr === ansr;

test[graf, previousResult]

True


Bob Hanlon


On Sun, Sep 16, 2012 at 3:25 AM, James Stein <mathgroup@stein.org> wrote:
>
> To my surprise, if you copy a Graphic  from a notebook and paste it
> elsewhere in the notebook, the Graphic objects are not the same (even
> though their visual appearance is identical.
>
> I discovered this irritation attempting regression testing. Here's an
> example: assume you have a function 'test' that takes two arguments:
>      test [ expression_, expectedResult _]
> An overly simple implementation might be this:
>     SetAttributes [ test, HoldAll ] ;
>     test [ expr_, ansr_ ] := expr === ansr;
> Now suppose you wish to verify that some routine, say  'graf', is still
> giving the same result it it did previously. Here is an example:
>
>     graf := ListPlot [ { 1, 2, 2, 3 }, ImageSize->Tiny ];
>     test [ graf , previousResult ] // Print;
>
> What should 'previousResult' be? You might consider copying the graphic
> produced by 'graf' earlier, which was correct, and paste it into 'test' as
> the second argument. Unfortunately, the action of copy & paste changes the
> internal structure of Graphic [ a1, a2, ... ] so the regression test will
> always fail.
>
> Questions:
> (1) Is there a good reason for this? (The unwashed are curious.)
> (2) Is this a bug (or 'feature') that could be fixed?
> (3) Is there a way to prevent it?
> (4) Is there an algorithm to do one of
>   (a) convert an original Graphic to its pasted form.
>   (b) convert a pasted Graphic to its original form.
>   (c) convert any Graphic to a canonical form, such that any two Graphic
> objects that produce identical displays will have identical canonical forms.
>
> For the truly curious, here are the differences in for a rather simple
> ListPlot I made. Let OG be the original, and CG be the pasted copy of OG.
>
> OG had Length 2; CG had Length 8.
>
> OG [[ 1 ]] was { { { }, {Hue[0.67, 0.6, 0.6], Point[{{1., 1.}, {2., 2.},
> {3., 2.}, {4., 3.}}]}, { } } }
> CG [[ 1 ]] was {   { }, {Hue[0.67, 0.6, 0.6], Point[{{1., 1.}, {2., 2.},
> {3., 2.}, {4., 3.}}]}, { }   }
>
> OG [ [ 2 ] ] was List of seven rules,
>
> OG [ [ 2 through 8 ] ] were the same seven rules.
>
> It would be simple to convert one of these trees to the other, but it would
> be rash to generalize the nature of the needed conversion without extensive
> investigations. Perhaps a  Wolfram wizzard can throw light on these
> questions, or someone can propose a different kind of regression testing to
> skirt the issue?
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Regression Testing of Graphics: some questions Bob Hanlon <hanlonr357@gmail.com> - 2012-09-17 04:28 +0000

csiph-web