1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

prettier printing for FPGroups

This commit is contained in:
Marek Kaluba 2021-12-18 19:34:04 +01:00
parent 5b5f3e3811
commit f2d2d4ee52
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 15 additions and 6 deletions

View File

@ -225,12 +225,21 @@ function FPGroup(
return FPGroup(G.gens, rels, rws)
end
function Base.show(io::IO, ::MIME"text/plain", G::FPGroup)
print(io, "Finitely presented group generated by:\n\t{")
Base.print_array(io, permutedims(gens(G)))
println(io, " },")
println(io, "subject to relations:")
return Base.print_array(io, relations(G))
end
function Base.show(io::IO, G::FPGroup)
print(io, "")
join(io, gens(G), ", ")
print(io, " | ")
join(io, relations(G), ", ")
return print(io, "")
Base.print_array(io, permutedims(gens(G)))
println(io, " | ")
print(io, "\t ")
Base.print_array(io, permutedims(relations(G)))
return print(io, "")
end
Base.show(io::IO, ::Type{<:FPGroup{T}}) where {T} =

View File

@ -96,7 +96,7 @@
@test evaluate(g*h) == evaluate(h*g)
@test (g*h).savedhash == zero(UInt)
@test sprint(show, typeof(g)) == "Automorphism{FreeGroup{Symbol}, …}"
@test sprint(show, typeof(g)) == "Automorphism{FreeGroup{Symbol, KnuthBendix.LenLex{Symbol}}, …}"
a = g*h
b = h*g

View File

@ -14,7 +14,7 @@
G = FPGroup(F, [a*b=>b*a, a*c=>c*a, b*c=>c*b])
@test G isa FPGroup
@test sprint(show, G) == "a, b, c | a*b => b*a, a*c => c*a, b*c => c*b"
@test sprint(show, G) == " a b c | \n\t a*b => b*a a*c => c*a b*c => c*b "
@test rand(G) isa FPGroupElement
f = a*c*b