If I want to display a large object (vector, array, matrix, etc) in the REPL, it will typically echo/display it, but incompletely with ellipses denoting the undisplayed/suppressed values.
Is there a way to override the length of the displayed object as a standard environment variable? It seems like this should be easy to do but I have not figured out a way to do it.
show() and @show will display an object but it’s just dumped without any formatting, which makes it difficult to read, and in any event, I have to do it on a case-by-case basis, rather than it being an environment/REPL setting.
I’ve tried using ENV[“LINES”] and setenv() but that doesn’t seem to work. Config() doesn’t seem to include anything related to this issue.
Any advice? It seems like this should be lurking somewhere in the REPL internals.
function edit!(x)
tmp_file_name = tempname()
writedlm(tmp_file_name,x)
InteractiveUtils.edit(tmp_file_name)
x .= readdlm(tmp_file_name)
end
With that, you can actually view the data and even edit it on your default text editor, with:
julia> x = rand(2,2)
2×2 Matrix{Float64}:
0.987879 0.215942
0.974738 0.975242
julia> edit!(x) # open vim and changed the first value to zero
2×2 Matrix{Float64}:
0.0 0.215942
0.974738 0.975242
Thanks. Your impression regarding lack of solutions is the same as mine. It’s surprising to me, as I’d think the default if anything would be to display the whole object, and that there would be an easy way to change the setting otherwise.
Slices sometimes works but sometimes you don’t really know.
I like your idea of the edit function. I’ve been trying it on my system; I can get it to open in an editor but then for some reason it usually crashes.
That specific function does not allow you to remove elements or other editions (because of the broadcasted reassignment of the values with .=). This is a little bit more general and perhaps useful, but has to be called with reassignment on return:
julia> using DelimitedFiles
julia> function edit!(x)
tmp_file_name = tempname()
writedlm(tmp_file_name,x)
InteractiveUtils.edit(tmp_file_name)
return readdlm(tmp_file_name)
end
edit! (generic function with 1 method)
julia> x = rand(2,2)
2×2 Matrix{Float64}:
0.913052 0.578263
0.254731 0.435317
julia> x = edit!(x) # note the reassignment (removed first line)
1×2 Matrix{Float64}:
0.254731 0.435317
Thanks — these are all great suggestions and very helpful. I agree with some of the comments in that issue thread that this could be made easier to address in the Julia docs. A dedicated topic in the REPL section might help.