Skip to content

Commit

Permalink
pretty printing for HeckeMap (#1213)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrandhorst authored Sep 19, 2023
1 parent c5f65d5 commit 3827bb4
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/Map/MapType.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3827bb4

Please sign in to comment.