Hi all,
I'm trying to write some pretty-print code for one of my packages. In particular, I want to print tensors, e.g. rand(3,3,3)
Now the (exported) options seem to be "print" and "dump"
For 2D:
julia> print(rand(3,3))
[0.9848410067397786 0.7395088321894974 0.08335407347392443
0.9908990998709222 0.6563403470680476 0.9422669325824669
0.967619446504451 0.995657061136656 0.14417657902926084]
+? Lots of precision
- Not aligned
- Square brackets
julia> dump(rand(3,3))
Array(Float64,(3,3)) 3x3 Array{Float64,2}:
0.60914 0.149033 0.431226
0.0413379 0.872331 0.24617
0.528959 0.225907 0.938011
+ Aligned
+ "Nice" amount of precision
- Type info
For 3D, the output of print is a bit confusing (just prints the three slices - not even clear which slices though), whereas dump prints something unambiguous
julia> dump(rand(2,2,2))
Array(Float64,(2,2,2)) 2x2x2 Array{Float64,3}:
[:, :, 1] =
0.698132 0.646175
0.0263156 0.721012
[:, :, 2] =
0.687558 0.0205718
0.89261 0.383277
Now I was digging around with auto-complete and found the un-exported function print_matrix which has the the alignment of dump, and precision of print - but only works for <= 2D.
Is there some (reasonable) way to export that nice dump functionality without the type info? I tried to trace the dump methods through but got lost.