How To Suppress Output of a Cell in Jupyter Notebook with Julia

Viewed 1966

I've been trying to figure out how to suppress the output of the last line in Jupyter Notebook with Julia. In particular, when the last line is an assignment. In Jupyter Notebook with a Python kernel, when I do

k=5

in a cell, no output is produced. However, in Julia, a simple assignment also returns a value, which makes the notebook visually redundant, and sometimes impossible to read with long return values. For example, when I have

using Random
Random.seed!(0) 

in a cell, the cell produces a very long output that contains pretty much unnecessary details.

MersenneTwister(UInt32[0x00000000], Random.DSFMT.DSFMT_state(Int32[748398797, 1073523691, -1738140313, 1073664641, -1492392947, 1073490074, -1625281839, 1073254801, 1875112882, 1073717145  …  943540191, 1073626624, 1091647724, 1073372234, -1273625233, -823628301, 835224507, 991807863, 382, 0]), [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], UInt128[0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000  …  0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000, 0x00000000000000000000000000000000], 1002, 0)

A related question suggested using the %%capture magic. However, this is not applicable to a Julia kernel.

Is there any simple way of suppressing such unnecessary output?

1 Answers

Ok I figured it out. The output can be disabled by simply appending a semicolon at the end of the last statement. A cell with

Random.seed!(0);

with produce no output.

Related