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

1

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?

jupyter-notebook
julia
asked on Stack Overflow May 17, 2020 by pkqxdd

1 Answer

1

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.

answered on Stack Overflow May 17, 2020 by pkqxdd

User contributions licensed under CC BY-SA 3.0