From c83ac031630fabc83550274e5204f320dbe628f3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 28 Feb 2024 02:47:05 +0100 Subject: [PATCH] Use @show_name, @show_special for all (?) parent show methods --- src/AbsMSeries.jl | 8 +++++++- src/Fraction.jl | 8 +++++++- src/FreeAssAlgebra.jl | 8 +++++++- src/LaurentMPoly.jl | 8 +++++++- src/MPoly.jl | 8 +++++++- src/Map.jl | 2 +- src/MatRing.jl | 2 +- src/NCPoly.jl | 2 ++ src/Poly.jl | 3 +++ src/RelSeries.jl | 8 +++++++- src/Residue.jl | 2 ++ src/ResidueField.jl | 2 ++ src/algorithms/LaurentPoly.jl | 6 +++++- src/generic/DirectSum.jl | 2 ++ src/generic/FunctionField.jl | 2 ++ src/generic/InvariantFactorDecomposition.jl | 4 ++++ src/generic/LaurentSeries.jl | 4 ++++ src/generic/Misc/Localization.jl | 2 ++ src/generic/PermGroups.jl | 2 ++ src/generic/PuiseuxSeries.jl | 4 ++++ src/generic/QuotientModule.jl | 4 ++++ src/generic/RationalFunctionField.jl | 2 ++ src/generic/SparsePoly.jl | 2 ++ src/generic/TotalFraction.jl | 2 ++ src/generic/UnivPoly.jl | 2 ++ src/generic/imports.jl | 2 ++ src/julia/GF.jl | 2 ++ 27 files changed, 94 insertions(+), 9 deletions(-) diff --git a/src/AbsMSeries.jl b/src/AbsMSeries.jl index 0425850141..353be32672 100644 --- a/src/AbsMSeries.jl +++ b/src/AbsMSeries.jl @@ -113,7 +113,10 @@ end @enable_all_show_via_expressify MSeriesElem -function show(io::IO, ::MIME"text/plain", p::MSeriesRing) +function show(io::IO, mime::MIME"text/plain", p::MSeriesRing) + @show_name(io, p) + @show_special(io, mime, p) + max_vars = 5 # largest number of variables to print n = nvars(p) print(io, "Multivariate power series ring") @@ -131,6 +134,9 @@ function show(io::IO, ::MIME"text/plain", p::MSeriesRing) end function show(io::IO, p::MSeriesRing) + @show_name(io, p) + @show_special(io, p) + if get(io, :supercompact, false) # no nested printing print(io, "Multivariate power series ring") diff --git a/src/Fraction.jl b/src/Fraction.jl index 3af548f2ad..bf54b943ad 100644 --- a/src/Fraction.jl +++ b/src/Fraction.jl @@ -131,7 +131,10 @@ end @enable_all_show_via_expressify FracElem -function show(io::IO, ::MIME"text/plain", a::FracField) +function show(io::IO, mime::MIME"text/plain", a::FracField) + @show_name(io, a) + @show_special(io, mime, a) + println(io, "Fraction field") io = pretty(io) print(io, Indent(), "of ", Lowercase(), base_ring(a)) @@ -139,6 +142,9 @@ function show(io::IO, ::MIME"text/plain", a::FracField) end function show(io::IO, a::FracField) + @show_name(io, a) + @show_special(io, a) + if get(io, :supercompact, false) print(io, "Fraction field") else diff --git a/src/FreeAssAlgebra.jl b/src/FreeAssAlgebra.jl index e80b575eba..cb1e554a30 100644 --- a/src/FreeAssAlgebra.jl +++ b/src/FreeAssAlgebra.jl @@ -59,7 +59,10 @@ end @enable_all_show_via_expressify FreeAssAlgElem -function show(io::IO, ::MIME"text/plain", a::FreeAssAlgebra) +function show(io::IO, mime::MIME"text/plain", a::FreeAssAlgebra) + @show_name(io, a) + @show_special(io, mime, a) + max_vars = 5 # largest number of variables to print n = nvars(a) print(io, "Free associative algebra") @@ -77,6 +80,9 @@ function show(io::IO, ::MIME"text/plain", a::FreeAssAlgebra) end function show(io::IO, a::FreeAssAlgebra) + @show_name(io, a) + @show_special(io, a) + if get(io, :supercompact, false) # no nested printing print(io, "Free associative algebra") diff --git a/src/LaurentMPoly.jl b/src/LaurentMPoly.jl index 95af3ec10b..3719bb8556 100644 --- a/src/LaurentMPoly.jl +++ b/src/LaurentMPoly.jl @@ -32,7 +32,10 @@ end @enable_all_show_via_expressify LaurentMPolyRingElem -function show(io::IO, ::MIME"text/plain", p::LaurentMPolyRing) +function show(io::IO, mime::MIME"text/plain", p::LaurentMPolyRing) + @show_name(io, p) + @show_special(io, mime, p) + max_vars = 5 # largest number of variables to print n = nvars(p) print(io, "Multivariate Laurent polynomial ring") @@ -50,6 +53,9 @@ function show(io::IO, ::MIME"text/plain", p::LaurentMPolyRing) end function show(io::IO, p::LaurentMPolyRing) + @show_name(io, p) + @show_special(io, p) + if get(io, :supercompact, false) # no nested printing print(io, "Multivariate Laurent polynomial ring") diff --git a/src/MPoly.jl b/src/MPoly.jl index ea5646c97c..bda9f35e4d 100644 --- a/src/MPoly.jl +++ b/src/MPoly.jl @@ -559,7 +559,10 @@ end @enable_all_show_via_expressify MPolyRingElem -function show(io::IO, ::MIME"text/plain", p::MPolyRing) +function show(io::IO, mime::MIME"text/plain", p::MPolyRing) + @show_name(io, p) + @show_special(io, mime, p) + max_vars = 5 # largest number of variables to print n = nvars(p) print(io, "Multivariate polynomial ring") @@ -577,6 +580,9 @@ function show(io::IO, ::MIME"text/plain", p::MPolyRing) end function show(io::IO, p::MPolyRing) + @show_name(io, p) + @show_special(io, p) + if get(io, :supercompact, false) # no nested printing print(io, "Multivariate polynomial ring") diff --git a/src/Map.jl b/src/Map.jl index a5255261b3..1ba9560efa 100644 --- a/src/Map.jl +++ b/src/Map.jl @@ -21,7 +21,7 @@ function check_composable(a::Map, b::Map) codomain(a) !== domain(b) && error("Incompatible maps") end -function Base.show(io::IO, ::MIME"text/plain", M::AbstractAlgebra.Map) +function Base.show(io::IO, mime::MIME"text/plain", M::AbstractAlgebra.Map) # the "header" is identical to the supercompact output; this # allows other map types to reuse this method println(IOContext(io, :supercompact => true), M) diff --git a/src/MatRing.jl b/src/MatRing.jl index d8b3b7ff3b..aa8db1a41b 100644 --- a/src/MatRing.jl +++ b/src/MatRing.jl @@ -161,7 +161,7 @@ is_square(a::MatRingElem) = true # ############################################################################### -function show(io::IO, ::MIME"text/plain", a::MatRing) +function show(io::IO, mime::MIME"text/plain", a::MatRing) print(io, "Matrix ring of") print(io, " degree ", a.n) println(io) diff --git a/src/NCPoly.jl b/src/NCPoly.jl index 7b1371650b..efa937ef6e 100644 --- a/src/NCPoly.jl +++ b/src/NCPoly.jl @@ -150,6 +150,8 @@ number_of_generators(R::NCPolyRing) = 1 ############################################################################### function show(io::IO, p::NCPolyRing) + @show_name(io, p) + @show_special(io, p) io = pretty(io) print(io, "Univariate polynomial ring in ", var(p), " over ") print(IOContext(io, :compact => true), Lowercase(), base_ring(p)) diff --git a/src/Poly.jl b/src/Poly.jl index 9d3d41afb6..5f547a9703 100644 --- a/src/Poly.jl +++ b/src/Poly.jl @@ -466,6 +466,9 @@ end @enable_all_show_via_expressify Union{PolynomialElem, NCPolyRingElem} function show(io::IO, p::PolyRing) + @show_name(io, p) + @show_special(io, p) + if get(io, :supercompact, false) print(io, "Univariate polynomial ring") else diff --git a/src/RelSeries.jl b/src/RelSeries.jl index 4e6c577345..bee8862be3 100644 --- a/src/RelSeries.jl +++ b/src/RelSeries.jl @@ -275,7 +275,10 @@ end @enable_all_show_via_expressify SeriesElem -function show(io::IO, ::MIME"text/plain", a::SeriesRing) +function show(io::IO, mime::MIME"text/plain", a::SeriesRing) + @show_name(io, a) + @show_special(io, mime, a) + print(io, "Univariate power series ring in ", var(a), " with precision ", a.prec_max) println(io) io = pretty(io) @@ -284,6 +287,9 @@ function show(io::IO, ::MIME"text/plain", a::SeriesRing) end function show(io::IO, a::SeriesRing) + @show_name(io, a) + @show_special(io, a) + if get(io, :supercompact, false) print(io, "Univariate power series ring") else diff --git a/src/Residue.jl b/src/Residue.jl index 7945b2414f..5c53497bbb 100644 --- a/src/Residue.jl +++ b/src/Residue.jl @@ -142,6 +142,8 @@ end @enable_all_show_via_expressify ResElem function show(io::IO, a::ResidueRing) + @show_name(io, a) + @show_special(io, a) if get(io, :supercompact, false) print(io, "Residue ring") else diff --git a/src/ResidueField.jl b/src/ResidueField.jl index 7c86661ee8..f0eccddb6f 100644 --- a/src/ResidueField.jl +++ b/src/ResidueField.jl @@ -132,6 +132,8 @@ end @enable_all_show_via_expressify ResFieldElem function show(io::IO, a::ResidueField) + @show_name(io, a) + @show_special(io, a) if get(io, :supercompact, false) print(io, "Residue field") else diff --git a/src/algorithms/LaurentPoly.jl b/src/algorithms/LaurentPoly.jl index a342805507..67c6aa1f29 100644 --- a/src/algorithms/LaurentPoly.jl +++ b/src/algorithms/LaurentPoly.jl @@ -203,7 +203,9 @@ canonical_unit(x::LaurentPolyRingElem) = canonical_unit(leading_coefficient(x)) # ############################################################################### -function show(io::IO, ::MIME"text/plain", p::LaurentPolyRing) +function show(io::IO, mime::MIME"text/plain", p::LaurentPolyRing) + @show_name(io, p) + @show_special(io, mime, p) print(io, "Univariate Laurent polynomial ring in ", var(p)) println(io) io = pretty(io) @@ -212,6 +214,8 @@ function show(io::IO, ::MIME"text/plain", p::LaurentPolyRing) end function show(io::IO, p::LaurentPolyRing) + @show_name(io, p) + @show_special(io, p) if get(io, :supercompact, false) print(io, "Univariate Laurent polynomial ring") else diff --git a/src/generic/DirectSum.jl b/src/generic/DirectSum.jl index 1500d41fc6..d7d9f72bed 100644 --- a/src/generic/DirectSum.jl +++ b/src/generic/DirectSum.jl @@ -44,6 +44,8 @@ summands(M::DirectSumModule{T}) where T <: RingElement = M.m ############################################################################### function show(io::IO, N::DirectSumModule{T}) where T <: RingElement + @show_name(io, N) + @show_special(io, N) if get(io, :supercompact, false) io = pretty(io) print(io, LowercaseOff(), "DirectSumModule") diff --git a/src/generic/FunctionField.jl b/src/generic/FunctionField.jl index e79a936040..fecebab9a4 100644 --- a/src/generic/FunctionField.jl +++ b/src/generic/FunctionField.jl @@ -772,6 +772,8 @@ end @enable_all_show_via_expressify FunctionFieldElem function show(io::IO, R::FunctionField) + @show_name(io, R) + @show_special(io, R) print(IOContext(io, :compact => true), "Function Field over ", base_ring(base_ring(R)), " with defining polynomial ", numerator(R)) diff --git a/src/generic/InvariantFactorDecomposition.jl b/src/generic/InvariantFactorDecomposition.jl index ab5562e8b7..98b958a1e8 100644 --- a/src/generic/InvariantFactorDecomposition.jl +++ b/src/generic/InvariantFactorDecomposition.jl @@ -56,6 +56,8 @@ end ############################################################################### function show(io::IO, N::SNFModule{T}) where T <: RingElement + @show_name(io, N) + @show_special(io, N) print(io, "Invariant factor decomposed module over ") print(IOContext(io, :compact => true), base_ring(N)) print(io, " with invariant factors ") @@ -63,6 +65,8 @@ function show(io::IO, N::SNFModule{T}) where T <: RingElement end function show(io::IO, N::SNFModule{T}) where T <: FieldElement + @show_name(io, N) + @show_special(io, N) print(io, "Vector space over ") print(IOContext(io, :compact => true), base_ring(N)) print(io, " with dimension ") diff --git a/src/generic/LaurentSeries.jl b/src/generic/LaurentSeries.jl index 7581a4d8da..7d72b4c716 100644 --- a/src/generic/LaurentSeries.jl +++ b/src/generic/LaurentSeries.jl @@ -517,6 +517,8 @@ function Base.show(io::IO, a::LaurentSeriesElem) end function show(io::IO, p::LaurentSeriesRing) + @show_name(io, p) + @show_special(io, p) if get(io, :supercompact, false) print(io, "Laurent series ring") else @@ -527,6 +529,8 @@ function show(io::IO, p::LaurentSeriesRing) end function show(io::IO, p::LaurentSeriesField) + @show_name(io, p) + @show_special(io, p) if get(io, :supercompact, false) print(io, "Laurent series field") else diff --git a/src/generic/Misc/Localization.jl b/src/generic/Misc/Localization.jl index 5ba7286a71..a9c939b2e5 100644 --- a/src/generic/Misc/Localization.jl +++ b/src/generic/Misc/Localization.jl @@ -166,6 +166,8 @@ function show(io::IO, a::LocalizedEuclideanRingElem) end function show(io::IO, L::LocalizedEuclideanRing) + @show_name(io, L) + @show_special(io, L) if L.comp print(io, "Localization of ", base_ring(L), " at complement of ", prime(L)) else diff --git a/src/generic/PermGroups.jl b/src/generic/PermGroups.jl index 7beb05f433..453e47b17a 100644 --- a/src/generic/PermGroups.jl +++ b/src/generic/PermGroups.jl @@ -279,6 +279,8 @@ permtype(g::Perm) = sort!(diff(cycles(g).cptrs), rev=true) ############################################################################### function show(io::IO, G::SymmetricGroup) + @show_name(io, G) + @show_special(io, G) print(io, "Full symmetric group over $(G.n) elements") end diff --git a/src/generic/PuiseuxSeries.jl b/src/generic/PuiseuxSeries.jl index 219f24c8b8..f850a68d69 100644 --- a/src/generic/PuiseuxSeries.jl +++ b/src/generic/PuiseuxSeries.jl @@ -313,6 +313,8 @@ function Base.show(io::IO, a::PuiseuxSeriesElem) end function show(io::IO, p::PuiseuxSeriesRing) + @show_name(io, p) + @show_special(io, p) if get(io, :supercompact, false) print(io, "Puiseux series ring") else @@ -323,6 +325,8 @@ function show(io::IO, p::PuiseuxSeriesRing) end function show(io::IO, p::PuiseuxSeriesField) + @show_name(io, p) + @show_special(io, p) if get(io, :supercompact, false) print(io, "Puiseux series field") else diff --git a/src/generic/QuotientModule.jl b/src/generic/QuotientModule.jl index bf8838cfbf..e27d704d8a 100644 --- a/src/generic/QuotientModule.jl +++ b/src/generic/QuotientModule.jl @@ -64,12 +64,16 @@ function show_gens_rels(io::IO, N::AbstractAlgebra.FPModule{T}) where T <: RingE end function show(io::IO, N::QuotientModule{T}) where T <: RingElement + @show_name(io, N) + @show_special(io, N) print(io, "Quotient module over ") print(IOContext(io, :compact => true), base_ring(N)) show_gens_rels(io, N) end function show(io::IO, N::QuotientModule{T}) where T <: FieldElement + @show_name(io, N) + @show_special(io, N) println(io, "Quotient space over:") print(IOContext(io, :compact => true), base_ring(N)) show_gens_rels(io, N) diff --git a/src/generic/RationalFunctionField.jl b/src/generic/RationalFunctionField.jl index 58d063c207..d8cb8f7453 100644 --- a/src/generic/RationalFunctionField.jl +++ b/src/generic/RationalFunctionField.jl @@ -155,6 +155,8 @@ function show(io::IO, ::MIME"text/plain", a::RationalFunctionField) end function show(io::IO, a::RationalFunctionField) + @show_name(io, a) + @show_special(io, a) if get(io, :supercompact, false) # no nested printing print(io, "Rational function field") diff --git a/src/generic/SparsePoly.jl b/src/generic/SparsePoly.jl index 95111ab1a9..feeef83d07 100644 --- a/src/generic/SparsePoly.jl +++ b/src/generic/SparsePoly.jl @@ -109,6 +109,8 @@ function Base.show(io::IO, a::SparsePoly) end function show(io::IO, p::SparsePolyRing) + @show_name(io, p) + @show_special(io, p) print(io, "Sparse Univariate Polynomial Ring in ") print(io, string(p.S)) print(io, " over ") diff --git a/src/generic/TotalFraction.jl b/src/generic/TotalFraction.jl index 74b47f394a..07002109d0 100644 --- a/src/generic/TotalFraction.jl +++ b/src/generic/TotalFraction.jl @@ -137,6 +137,8 @@ end @enable_all_show_via_expressify TotFrac function show(io::IO, a::TotFracRing) + @show_name(io, a) + @show_special(io, a) print(IOContext(io, :compact => true), "Total ring of fractions of ", base_ring(a)) end diff --git a/src/generic/UnivPoly.jl b/src/generic/UnivPoly.jl index 566337508a..82b8b0f550 100644 --- a/src/generic/UnivPoly.jl +++ b/src/generic/UnivPoly.jl @@ -334,6 +334,8 @@ end ############################################################################### function show(io::IO, R::UniversalPolyRing) + @show_name(io, R) + @show_special(io, R) print(io, "Universal Polynomial Ring over ") show(io, base_ring(R)) end diff --git a/src/generic/imports.jl b/src/generic/imports.jl index 6f8f18e77e..694a2bcf7b 100644 --- a/src/generic/imports.jl +++ b/src/generic/imports.jl @@ -73,6 +73,8 @@ using ..AbstractAlgebra import ..AbstractAlgebra: @attributes import ..AbstractAlgebra: @enable_all_show_via_expressify +import ..AbstractAlgebra: @show_name +import ..AbstractAlgebra: @show_special import ..AbstractAlgebra: CacheDictType import ..AbstractAlgebra: CycleDec import ..AbstractAlgebra: Dedent diff --git a/src/julia/GF.jl b/src/julia/GF.jl index 6ff71a1ded..1531244bb2 100644 --- a/src/julia/GF.jl +++ b/src/julia/GF.jl @@ -132,6 +132,8 @@ function show(io::IO, x::GFElem) end function show(io::IO, R::GFField) + @show_name(io, R) + @show_special(io, R) print(io, "Finite field F_", R.p) end