Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
felixcremer opened this issue Jul 17, 2023 · 4 comments
Closed

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

felixcremer opened this issue Jul 17, 2023 · 4 comments
Labels

Comments

@felixcremer
Copy link
Contributor

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
Copy link
Owner

rafaqz commented Jul 21, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@rafaqz
Copy link
Owner

rafaqz commented Feb 29, 2024

This is forwarded now:

Base.show(io::IO, A::AbstractDimArray) = show(io, parent(A))

@rafaqz rafaqz closed this as completed Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants