Skip to content

Commit

Permalink
make Collection{<:NewBandRep} print more like BandRep
Browse files Browse the repository at this point in the history
  • Loading branch information
thchr committed Sep 16, 2024
1 parent ab67c6f commit eb1b277
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,41 @@ function Base.show(io :: IO, ::MIME"text/plain", br :: NewBandRep)
end
function Base.show(io :: IO, br :: NewBandRep)
print(io, "(", label(position(br.siteir)), "|", label(br.siteir), ")")
end

# ---------------------------------------------------------------------------------------- #
# Collection{<:NewBandRep}

@eval Crystalline function Base.show(io :: IO, ::MIME"text/plain", brs :: Collection{<:NewBandRep})
irlabs = irreplabels(brs)
Nⁱʳʳ = length(irlabs)

# print a "summary" line
print(io, length(brs), "-element ", typeof(brs), " for ⋕", num(brs))
print(io, " (", iuc(num(brs), dim(brs)), ") ")
print(io, "over ", Nⁱʳʳ, " irreps")
print(io, " (spin-", first(brs).spinful ? "½" : "1",
" w/", first(brs).timereversal ? "" : "o", "TR):")
println(io)

# print band representations as table
k_idx = (i) -> findfirst(==(klabel(irreplabels(brs)[i])), klabels(brs)) # highlighters
h_odd = Highlighter((data,i,j) -> iNⁱʳʳ && isodd(k_idx(i)), crayon"light_blue")
h_μ = Highlighter((data,i,j) -> i==Nⁱʳʳ+1, crayon"light_yellow")
pretty_table(io,
# table contents
stack(brs);
# row/column names
row_labels = vcat(irlabs, "μ"),
header = (label.(position.(brs)), label.(siteirrep.(brs))),
# options/formatting/styling
formatters = (v,i,j) -> iszero(v) ? "·" : string(v),
vlines = [1,], hlines = [:begin, 1, Nⁱʳʳ+1, :end],
row_label_alignment = :l,
alignment = :c,
highlighters = (h_odd, h_μ),
header_crayon = crayon"bold"
# TODO: Would be nice to highlight the `row_labels` in a style matching the contents,
# but not possible atm (https://github.com/ronisbr/PrettyTables.jl/issues/122)
)
end

0 comments on commit eb1b277

Please sign in to comment.