-
Notifications
You must be signed in to change notification settings - Fork 148
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
repr
roundtripping. "print it like you build it"
#692
Comments
Good issue, thanks! I certainly think we could try changing julia> repr(SA[1,2,3])
"[1, 2, 3]"
julia> repr(SA[SA_F32[1,2,3], SA_F32[4,5,6]])
"SArray{Tuple{3},Float32,1,3}[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]" which is compact but not entirely ideal when printing nested data structures. julia> repr(SA[1,2,3])
"SA[1, 2, 3]"
julia> repr(SA[SA_F32[1,2,3], SA_F32[4,5,6]])
"SA[SA_F32[1.0, 2.0, 3.0], SA_F32[4.0, 5.0, 6.0]]" or some similar printing which generates the correct type and doesn't imply creating any Would you be interested in giving it a go? There's several functions to think about ( |
Something as simple as function Base.show(io::IO, a::SArray{S,T}) where {S,T}
print(io, "SArray{$(S),$(T)}")
print(io, Tuple(vec(a)))
end could take care of this. Special casing I am happy to make a PR (with tests etc) if there is interest. |
This allows SArray and MArray to be printed (show, repr, etc) and read back into an object of the same type. Fixes JuliaArrays#692.
I'm not sure if there are any functions in the display/show/repr family that are supposed to obey it, but it would be nice if
a_rt === a
(to the extent that everything isbitstype
) in the followingoutput:
(related a bit to the conversation in #691.
The text was updated successfully, but these errors were encountered: