3
$\begingroup$

From time to time I accidentally let large expressions like RandomReal[1., {10^5, 10, 10}] reach the front end. The computation of the result is quite fast (AbsoluteTiming gives 0.0896609), but the kernel will still take a very long time, just to finally display the 'large output' widget.

Sometimes I can abort the "output-computation" to avoid waiting, but I cannot know when the actual computation that I want to finish ends.

Is there a way to have the front-end do something different on large output? Maybe applying something like Short to large results instead of the 'large output' widget, though Short also seems to be slow. Dimensions might be preferable.

Are there any hooks for this?

$\endgroup$
2
$\begingroup$

This can be of help

$PrePrint = If[ByteCount[#] > 10^6, Shallow[#, 1], #] &

Maybe something more fancy is needed to pass larger Graphics, it is up to you.

You can put it init.m analogously to: What bug fixes can be implemented in init.m?

$\endgroup$
  • $\begingroup$ Unfortunately, this causes weird and hard-to-track error messages with say Plot3D: After setting this, e.g. Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, PerformanceGoal -> "Quality", PlotPoints -> 100, BoxRatios -> Automatic] will print an error message saying "Skeleton is not a Graphics3D primitive or directive" $\endgroup$ – masterxilo Aug 16 '16 at 16:05
  • $\begingroup$ @masterxilo That is what I was anticipating in the line below the code block. You can try to adjust it, analogously to: Why are graphics rendered as MathML when I set $PrePrint = MathMLForm? $\endgroup$ – Kuba Aug 16 '16 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.