-
Notifications
You must be signed in to change notification settings - Fork 1
improve display #40
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
improve display #40
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
=======================================
Coverage 94.32% 94.32%
=======================================
Files 20 20
Lines 775 776 +1
=======================================
+ Hits 731 732 +1
Misses 44 44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Looks good, can you add a few tests? julia> sprint(show, [1, 2, 3]) == "[1, 2, 3]"
true
julia> sprint(show, MIME("text/plain"), [1, 2, 3]) == "3-element Vector{Int64}:\n 1\n 2\n 3"
true |
I know this is already merged, but as a minor comment for possible improvements: if you print module NotInNameSpace
using GradedArrays: GradedArrays
println(typeof(GradedArrays.O2(1))) # GradedArrays.O2
end
using GradedArrays: O2
println(typeof(O2(1))) # O2 |
Good point, that sounds helpful to add. Base.summary could be helpful for that. |
Here I do not display the full type to get an easier to read, less verbose output and hide implementation details: julia> gradedrange([U1(1)× O2(1)×SU2(1//2)×SU{3}((1,0))=>1])
GradedArrays.GradedUnitRange{Int64, GradedArrays.SectorUnitRange{Int64, GradedArrays.SectorProduct{Tuple{U1{Int64}, O2, SU{2, 1}, SU{3, 2}}}, Base.OneTo{Int64}}, BlockedOneTo{Int64, Vector{Int64}}, Vector{Int64}}
SectorUnitRange (U1(1) × O2(1) × SU2(1/2) × SU{3}((1, 0))) => 1:12
julia> println(gradedrange([U1(1)× O2(1)×SU2(1//2)×SU{3}((1,0))=>1]))
GradedUnitRange[(U1(1) × O2(1) × SU2(1/2) × SU{3}((1, 0))) => 12] Using julia> gradedrange([U1(1)× O2(1)×SU2(1//2)×SU{3}((1,0))=>1])
GradedArrays.GradedUnitRange{Int64, GradedArrays.SectorUnitRange{Int64, GradedArrays.SectorProduct{Tuple{U1{Int64}, O2, SU{2, 1}, SU{3, 2}}}, Base.OneTo{Int64}}, BlockedOneTo{Int64, Vector{Int64}}, Vector{Int64}}
SectorUnitRange (U1{Int64}(1) × O2(1) × SU{2, 1}((1,)) × SU{3, 2}((1, 0))) => 1:12
julia> println(gradedrange([U1(1)× O2(1)×SU2(1//2)×SU{3}((1,0))=>1]))
GradedUnitRange[(U1{Int64}(1) × O2(1) × SU{2, 1}((1,)) × SU{3, 2}((1, 0))) => 12] Indeed to copy paste in RHEL I need to import the names. I have a weak preference for the current choice as I find it easier to read and parse. |
I was definitely proposing this only for the 2-arg version, I agree that for 3-arg you want human-readable. I'm okay with either, just wanted to mention this. |
I think you could customize But anyway, I don't think we need to do this right now, I think the printing change in this PR is good and we can keep in mind fancier things for the future. |
This PR improves display for sectors
U1
,O2
,SU2
andSU{N}
. The objective is that the output ofprintln(s::AbstractSector)
can be directly copy pasted into RHEL to produce the same sector.