b-fg / OutMacro.jl

Pretty print for a variable(s) using `display`-like output and a `@show`-like header.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OutMacro.jl

OutMacro.jl packages the @out macro which mimics @show but breaking the output in multiple lines for a prettier display (similarly to display(x)).

It is specially useful for debugging variables in the REPL: arrays get their variable name displayed together with the size and a pretty output for their values. Still, the printed output is not "copy-paste"-ready in the REPL, which is the main reason this was not finally included in @show.

Installation and usage

OutMacro.jl is registered in the official Julia package registry and it can be installed and used with:

julia> using Pkg; Pkg.add("OutMacro")
julia> using OutMacro

Examples

Single variable:

julia> a = [1, 2, 3, 4];
julia> @out a;
a = 4-element Vector{Int64}:
 1
 2
 3
 4

Multiple variables:

julia> a = [1, 2, 3, 4];
julia> b = zeros(4, 4);
julia> @out(a, b);
a = 4-element Vector{Int64}:
 1
 2
 3
 4
b = 4×4 Matrix{Float64}:
 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

Acknowledgement and references

The original PR contribution by @matthieugomez can be found here. This topic was further discussed in Julia Discourse here.

About

Pretty print for a variable(s) using `display`-like output and a `@show`-like header.

License:Other


Languages

Language:Julia 100.0%