MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Regression Testing of Graphics: some questions

  • To: mathgroup at
  • Subject: [mg128112] Re: Regression Testing of Graphics: some questions
  • From: "Nasser M. Abbasi" <nma at>
  • Date: Mon, 17 Sep 2012 00:19:28 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <k33upt$quq$>
  • Reply-to: nma at

On 9/16/2012 2:23 AM, James Stein wrote:

> 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.)

I played a little with this. What I found is that when you copy then
paste an image using the mouse, and then look at the FullForm of the
copied image, (the FullForm is the true data for all expression in
Mathematica)then the FullForm is not exactly the same. This is why
the test you have above using === failed.

For an example, using your  graf plot

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

The FullForm starts with this line

       Graphics[List[List[List[], List[Hue[0.67, 0.6, 0.6]

But the copy/pasted image FullForm starts with this line

       Graphics[List[List[], List[Hue[0.67, 0.6, 0.6]

Even though they look at the same on the screen (obviously), the
FullForm is not the same.   One has an extra List wrapper as you
can see.

The button line, you can't assume that a copy/pasted image
will remain the same in the sense of its FullForm remain the same
as this case shows.  There might be a way to copy/paste an image
so that the copy will have the same FullForm. may be a Mathematica
expert knows how to do that.

btw, for doing diffs' between notebooks or cells, I use this free web

I use it all the time to diff my notebooks to see what changes I made.
(I think the notebook itself should have something like this build into it).

Just copy paste the Mathematica code (right click the cell,
copy (can also do copyAs Text, but normal Copy will show also the RowBoxes
and all the internal detailed), then paste right into the above
web page little left window) and do the same for the other cell or
notebook and paste into the right winodw and then click 'see the difference'
button. This web site will show you the differences using colors
and line numbers also.

Here is a screen shot showing the differences between your graf
and its copy/pasted version


  • Prev by Date: Re: Mathematica's FindMinimum does not solve trivial optimization problems
  • Next by Date: Re: Regression Testing of Graphics: some questions
  • Previous by thread: Re: Regression Testing of Graphics: some questions
  • Next by thread: FindMinimum does not free memory