rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
280 stars 41 forks source link

println of a DimArray shows all values in the array #498

Closed felixcremer closed 8 months ago

felixcremer commented 1 year ago

When I use println to print a DimArray it does not show the nice formatted printing of the Axes but only prints the values in the array. This is a huge footgun, because it can lead to printing multi GB worth of data. I ran into it, when I wanted to print a subsetted array into a textfile to see the size of the dimensions, and then it printed the whole dataset into it.

When we replace the Base.show method with the MIME type by the 2-arg method without the MIME type this works as expected. I can prepare a PR.

rafaqz commented 1 year ago

Yes I have just left the default AbstractArray behaviour. Raw show is usually not pretty printed.

You could also use sprint with "text/plain" instead of print ?

felixcremer commented 9 months ago

We do not want to change this behaviour in DimensionalData because we would like to see the values of small arrays. We should implement show(io, A) for YAXArrays and Rasters because the show methods do not hit the show of the underlying DiskArray.

felixcremer commented 9 months ago

We can just forward the show(io, A) function to the parent(A).

rafaqz commented 8 months ago

This is forwarded now: https://github.com/rafaqz/DimensionalData.jl/blob/f5468f2d654d0d6dd9f4c27c9a45efd5222edbf8/src/array/show.jl#L21