2
$\begingroup$

(MMA 9.0.0 on Mac OS/X 10.8)

Please consider the following snippet (this is as SMALL as I could make it -- my attempts at making a smaller repro-case eliminated the effect that I am investigating)

Manipulate[
 With[{img = 
    Image@RandomVariate[
      NormalDistribution[0.5 + p - p, 0.25], {25, 25}]},
  With[{grf =
     (* comment the following line to stop
     the double-evaluation *)
     MorphologicalGraph@
      ColorNegate@
       Image@
        WatershedComponents@
         Binarize@
          img},
   GraphicsGrid[{{img, grf}}]
   ]],
 (* click the + on the controller, wait a second,
 and you will see double-evaluation *)
 {p, 1, 10, 1, 
  Appearance -> "Open"}]

In the interactive block that results, press the + and - keys to advance or retract the value of p. If you are patient, on each press of + or -, after a delay of 1 second or so, the entire display will evaluate a second time. This behavior is rather obvious and jarring since the generated image and graph are random.

If you remove the call of MorphologicalGraph, the behavior does not happen. Somehow, MorphologicalGraph seems to be (hypothetically) causing an extra evaluation step after a 'settling time'.

I'd like to at least understand this behavior if not get rid of it.

$\endgroup$
5
  • 2
    $\begingroup$ I think this is an attempt of Manipulate to first calculate the result quickly, then calculate it accurately, thus having both responsiveness and accuracy. It's related to options such as PerformanceGoal and ControlActive but I can't find how to turn it off right now. Hope this info will help you search for the solution. Then there's also BlockRandom and SeedRandom for getting reproducible results from Random* functions. $\endgroup$
    – Szabolcs
    Commented Feb 15, 2013 at 16:20
  • 1
    $\begingroup$ See this too please: mathematica.stackexchange.com/questions/8373/… $\endgroup$
    – Szabolcs
    Commented Feb 15, 2013 at 16:23
  • 1
    $\begingroup$ mathematica.stackexchange.com/questions/8072/… $\endgroup$
    – Szabolcs
    Commented Feb 15, 2013 at 16:27
  • 2
    $\begingroup$ I'm not sure if this is a bug or not. Here's a more minimal test case: Manipulate[Column[{Pause[0.2]; x, $PerformanceGoal, $ControlActiveSetting}], {x, 0, 1}, ContinuousAction -> False]. ContinuousAction -> False fixes double evaluation when dragging the slider, but not when clicking the +/- buttons. The behaviour is the same in 8. $\endgroup$
    – Szabolcs
    Commented Feb 15, 2013 at 16:32
  • 1
    $\begingroup$ This seems to be fixed as of V10.0.0. $\endgroup$
    – Michael E2
    Commented Aug 8, 2015 at 20:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.