From 3827bb49cb87f0508cc2a04cff3475e66c9af5e9 Mon Sep 17 00:00:00 2001 From: Simon Brandhorst Date: Tue, 19 Sep 2023 08:55:34 +0200 Subject: [PATCH] pretty printing for HeckeMap (#1213) --- src/Map/MapType.jl | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Map/MapType.jl b/src/Map/MapType.jl index 59680f5e44..04cc275888 100644 --- a/src/Map/MapType.jl +++ b/src/Map/MapType.jl @@ -148,18 +148,27 @@ object `f`. If `g` is provided, it is assumed to satisfy julia> F = GF(2); julia> f = MapFromFunc(QQ, F, x -> F(numerator(x)) * inv(F(denominator(x)))) -Map from -Rational field to Finite field of characteristic 2 defined by a julia-function +Map defined by a julia-function + from rational field + to finite field of characteristic 2 julia> f(QQ(1//3)) 1 +julia> println(f) +Map: QQ -> GF(2) + julia> f = MapFromFunc(QQ, F, x -> F(numerator(x)) * inv(F(denominator(x))), y -> QQ(lift(y)),) -Map from -Rational field to Finite field of characteristic 2 defined by a julia-function with inverse +Map defined by a julia-function with inverse + from rational field + to finite field of characteristic 2 julia> preimage(f, F(1)) 1 + +julia> println(f) +Map: QQ -> GF(2) + ``` """ mutable struct MapFromFunc{R, T} <: Map{R, T, HeckeMap, MapFromFunc} @@ -197,20 +206,16 @@ function preimage(f::MapFromFunc, y) return x end -function Base.show(io::IO, M::MapFromFunc) +function Base.show(io::IO, ::MIME"text/plain", M::MapFromFunc) @show_name(io, M) - - io = IOContext(io, :compact => true) -# println(io, "Map from the $(M.f) julia-function") - println(io, "Map from") - show(io, domain(M)) - print(io, " to ") - show(io, codomain(M)) - print(io, " defined by a julia-function") + io = pretty(io) + print(io, "Map defined by a julia-function") if isdefined(M, :g) -# println(io, "with inverse by $(M.g)") print(io, " with inverse") end + println(io) + println(io, Indent(),"from ", Lowercase(), domain(M)) + print(io, "to ", Lowercase(), codomain(M), Dedent()) end function MapFromFunc(D, C, f)