Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Watch" long array from Julia REPL?

Suppose I have a long array.

> using MakieGallery
> size(database)
(210,)

If I do

> [d.title for d=database]

it will print it truncated, and if I show it, it will print it into a mess:

> show([d.title for d=database])

I don't know how, but probably I could print values into a column and it would scroll my console far up.

All this is bad. Is it possible to do some sort of simple "watch" of a variable? I.e. open some small widget in separate window with a list control, diplaying an array, which I could scroll as needed?

like image 710
Dims Avatar asked Jun 27 '26 21:06

Dims


1 Answers

Internally Julia uses Base.show to display the values in the REPL, you can simply extend this function in any way you like (this example is just a really simple implementation to print every element of array in a new line and you probably shouldn't use it):

Base.show(io::IO, ::MIME"text/plain", x::Array) = x .|> println

You can then go on and add your function to .julia/config/startup.jl to load this every time you start the REPL. Just make sure to have a really solid implementation to handle various edge cases where it might not function properly.

like image 104
Agent Avatar answered Jun 30 '26 18:06

Agent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!