Skip to content

Commit

Permalink
Use new is_terse and terse functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed May 5, 2024
1 parent 006e9a3 commit ccfb47f
Show file tree
Hide file tree
Showing 64 changed files with 164 additions and 166 deletions.
16 changes: 8 additions & 8 deletions docs/src/DeveloperDocumentation/printing_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ where `io` is an `IO` object (such as `stdout` or an `IOBuffer`):
```
show(io, MIME"text/plain"(), x) # detailed printing
print(io, x) # one line printing
print(IOContext(io, :supercompact => true), x) # supercompact printing
print(terse(io), x) # supercompact printing
```

For reference, string interpolation `"$(x)"` uses one line printing via `print(io, x)`,
Expand Down Expand Up @@ -52,13 +52,13 @@ end
The following is a template for `one line` and `:supercompact` printing.
```julia
function Base.show(io::IO, R::NewRing)
if get(io, :supercompact, false)
if is_terse(io)
# no nested printing
print(io, "supercompact printing of newring ")
else
# nested printing allowed, preferably supercompact
print(io, "one line printing of newring with ")
print(IOContext(io, :supercompact => true), "supercompact ", base_ring(R))
print(terse(io), "supercompact ", base_ring(R))
end
end
```
Expand Down Expand Up @@ -91,13 +91,13 @@ end
base_ring(R::NewRing2) = R.base_ring

function Base.show(io::IO, R::NewRing2)
if get(io, :supercompact, false)
if is_terse(io)
# no nested printing
print(io, "supercompact printing of newring")
else
# nested printing allowed, preferably supercompact
print(io, "I am a new ring and always print in one line " )
print(IOContext(io, :supercompact => true), base_ring(R))
print(terse(io), base_ring(R))
end
end
```
Expand All @@ -111,7 +111,7 @@ julia> [R,R]
I am a new ring and always print in one line Rational Field
I am a new ring and always print in one line Rational Field

julia> print(IOContext(Base.stdout, :supercompact => true) ,R)
julia> print(terse(Base.stdout) ,R)
supercompact printing of newring
```

Expand Down Expand Up @@ -140,11 +140,11 @@ It will be used for `print(io, R::NewRing)` though.

```julia
function Base.show(io::IO, R::NewRing)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "supercompact printing of newring")
else # this is what we call one line
print(io, "one line printing of newring with ")
print(IOContext(io, :supercompact => true), "supercompact ", R.base_ring)
print(terse(io), "supercompact ", R.base_ring)
end
end
```
Expand Down
8 changes: 4 additions & 4 deletions docs/src/DeveloperDocumentation/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,17 @@ The print modes are specified as follows
- should make sense as a standalone without context
- variable names/generators/relations should not be printed only their number.
- Only the first word is capitalized e.g. `Polynomial ring`
- one should use `:supercompact` for nested printing in compact
- one should use `terse` for nested printing in compact
- nested calls to `one line` (if you think them really necessary) should be at the end,
so that one can read sequentially. Calls to `:supercompact` can be anywhere.
so that one can read sequentially. Calls to `terse` can be anywhere.
- commas must be enclosed in brackets so that printing tuples stays unambiguous
#### Super compact printing
#### Terse printing
- a user readable version of the main (mathematical) type.
- a single term or a symbol/letter mimicking mathematical notation
- should usually only depend on the type and not of the type parameters or of
the concrete instance - exceptions of this rule are possible e.g. for `GF(2)`
- no nested printing. In particular variable names and `base_ring` must not be displayed.
This ensures that `one line` and `:supercompact` stay compact even for complicated things.
This ensures that `one line` and `terse` stay compact even for complicated things.
If you want nested printing use `one line` or `detailed`.
For further information and examples we refer you to our section [Details on
Expand Down
4 changes: 2 additions & 2 deletions experimental/BasisLieHighestWeight/src/MonomialBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ function Base.show(io::IO, ::MIME"text/plain", basis::MonomialBasis)
end

function Base.show(io::IO, basis::MonomialBasis)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Monomial basis of a highest weight module")
else
io = pretty(io)
print(
io,
"Monomial basis of a highest weight module with highest weight $(highest_weight(basis)) over ",
)
print(IOContext(io, :supercompact => true), Lowercase(), base_lie_algebra(basis))
print(terse(io), Lowercase(), base_lie_algebra(basis))
end
end
2 changes: 1 addition & 1 deletion experimental/GModule/GaloisCohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ end
function Base.show(io::IO, m::MIME"text/plain", a::RelativeBrauerGroupElem)
io = pretty(io)
print(io, "Element of relative Brauer group of ", Lowercase(), parent(a).k)
io = IOContext(io, :supercompact => true, :compact => true)
io = terse(io)
print(io, Indent())
data = sort(collect(a.data); by =(x -> first(x) isa AbsSimpleNumFieldEmbedding ? Inf : minimum(first(x))))
for (p,v) in data
Expand Down
2 changes: 1 addition & 1 deletion experimental/InvariantTheory/src/InvariantTheory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Base.show(io::IO, G::LinearlyReductiveGroup)
io = pretty(io)
if G.group[1] == :SL
println(io, "Reductive group ", G.group[1], G.group[2])
print(IOContext(io, :supercompact => true), Indent(), "over ", Lowercase(), field(G))
print(terse(io), Indent(), "over ", Lowercase(), field(G))
print(io, Dedent())
end
end
Expand Down
4 changes: 2 additions & 2 deletions experimental/InvariantTheory/src/TorusInvariantsFast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ field(G::TorusGroup) = G.field
function Base.show(io::IO, G::TorusGroup)
io = pretty(io)
println(io, "Torus of rank ", rank(G))
print(IOContext(io, :supercompact => true), Indent(), "over ", Lowercase(), field(G))
print(terse(io), Indent(), "over ", Lowercase(), field(G))
print(io, Dedent())
end

Expand Down Expand Up @@ -152,7 +152,7 @@ group(R::RepresentationTorusGroup) = R.group
function Base.show(io::IO, R::RepresentationTorusGroup)
io = pretty(io)
println(io, "Representation of torus of rank ", rank(group(R)))
println(IOContext(io, :supercompact => true), Indent(), "over ", Lowercase(), field(group(R)), " and weights ")
println(terse(io), Indent(), "over ", Lowercase(), field(group(R)), " and weights ")
print(io, R.weights)
print(io, Dedent())
end
Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/AbstractLieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ function Base.show(io::IO, ::MIME"text/plain", L::AbstractLieAlgebra)
end

function Base.show(io::IO, L::AbstractLieAlgebra)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Abstract Lie algebra")
else
io = pretty(io)
print(io, "Abstract Lie algebra over ", Lowercase())
print(IOContext(io, :supercompact => true), coefficient_ring(L))
print(terse(io), coefficient_ring(L))
end
end

Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebraHom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ end

function Base.show(io::IO, ::MIME"text/plain", h::LieAlgebraHom)
io = pretty(io)
println(IOContext(io, :supercompact => true), h)
println(terse(io), h)
print(io, Indent())
println(io, "from ", Lowercase(), domain(h))
print(io, "to ", Lowercase(), codomain(h))
Expand All @@ -80,7 +80,7 @@ end

function Base.show(io::IO, h::LieAlgebraHom)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, LowercaseOff(), "Lie algebra morphism")
else
print(io, LowercaseOff(), "Lie algebra morphism: ")
Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebraIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ end

function Base.show(io::IO, I::LieAlgebraIdeal)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, LowercaseOff(), "Lie algebra ideal")
else
print(io, LowercaseOff(), "Lie algebra ideal of dimension $(dim(I)) over ", Lowercase())
print(IOContext(io, :supercompact => true), base_lie_algebra(I))
print(terse(io), base_lie_algebra(I))
end
end

Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebraModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ function _show_inner(io::IO, V::LieAlgebraModule)
end

function Base.show(io::IO, V::LieAlgebraModule)
if get(io, :supercompact, false)
if is_terse(io)
print(io, _module_type_to_string(V))
else
io = pretty(io)
print(io, _module_type_to_string(V), " of dimension $(dim(V)) over ", Lowercase())
print(IOContext(io, :supercompact => true), base_lie_algebra(V))
print(terse(io), base_lie_algebra(V))
end
end

Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebraModuleHom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end

function Base.show(io::IO, ::MIME"text/plain", h::LieAlgebraModuleHom)
io = pretty(io)
println(IOContext(io, :supercompact => true), h)
println(terse(io), h)
print(io, Indent())
println(io, "from ", Lowercase(), domain(h))
print(io, "to ", Lowercase(), codomain(h))
Expand All @@ -87,7 +87,7 @@ end

function Base.show(io::IO, h::LieAlgebraModuleHom)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, LowercaseOff(), "Lie algebra module morphism")
else
print(io, LowercaseOff(), "Lie algebra module morphism: ")
Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LieSubalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ end

function Base.show(io::IO, S::LieSubalgebra)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, LowercaseOff(), "Lie subalgebra")
else
print(io, LowercaseOff(), "Lie subalgebra of dimension $(dim(S)) of ", Lowercase())
print(IOContext(io, :supercompact => true), base_lie_algebra(S))
print(terse(io), base_lie_algebra(S))
end
end

Expand Down
4 changes: 2 additions & 2 deletions experimental/LieAlgebras/src/LinearLieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function Base.show(io::IO, ::MIME"text/plain", L::LinearLieAlgebra)
end

function Base.show(io::IO, L::LinearLieAlgebra)
if get(io, :supercompact, false)
if is_terse(io)
print(io, _lie_algebra_type_to_compact_string(get_attribute(L, :type, :unknown), L.n))
else
io = pretty(io)
Expand All @@ -101,7 +101,7 @@ function Base.show(io::IO, L::LinearLieAlgebra)
" over ",
Lowercase(),
)
print(IOContext(io, :supercompact => true), coefficient_ring(L))
print(terse(io), coefficient_ring(L))
end
end

Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/RootSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Base.show(io::IO, ::MIME"text/plain", R::RootSystem)
end

function Base.show(io::IO, R::RootSystem)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Root system")
else
print(io, "Root system defined by Cartan matrix $(cartan_matrix(R))")
Expand Down
4 changes: 2 additions & 2 deletions experimental/QuadFormAndIsom/src/printings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Base.show(io::IO, ::MIME"text/plain", Lf::ZZLatWithIsom)
end

function Base.show(io::IO, Lf::ZZLatWithIsom)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Integer lattice with isometry")
else
n = order_of_isometry(Lf)
Expand Down Expand Up @@ -54,7 +54,7 @@ function Base.show(io::IO, ::MIME"text/plain", Vf::QuadSpaceWithIsom)
end

function Base.show(io::IO, Vf::QuadSpaceWithIsom)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Quadratic space with isometry")
else
n = order_of_isometry(Vf)
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/AlgebraicCycles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function Base.show(io::IO, D::AlgebraicCycle)
end
if has_name(D)
print(io, name(D))
elseif get(io, :supercompact, false)
elseif is_terse(io)
print(io, "Algebraic cycle")
elseif length(components(D)) == 0
print(io, "Zero algebraic cycle on ", Lowercase(), scheme(D))
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/BlowupMorphism.jl
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ end
##############################################################################
function Base.show(io::IO, Bl::AbsSimpleBlowdownMorphism)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Blowup morphism")
else
print(io, "Blow-down: ", Lowercase(), domain(Bl))
Expand Down
4 changes: 2 additions & 2 deletions experimental/Schemes/CartierDivisor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function Base.show(io::IO, C::EffectiveCartierDivisor)
cov = Oscar._covering_for_printing(io, scheme(C))
n = get(io, :label, "")
_show_semi_compact(io, C, cov, n)
elseif get(io, :supercompact, false)
elseif is_terse(io)
print(io, "Effective cartier divisor")
elseif has_attribute(C, :name)
print(io, get_attribute(C, :name))
Expand Down Expand Up @@ -472,7 +472,7 @@ function Base.show(io::IO, C::CartierDivisor)
cov = Oscar._covering_for_printing(io, scheme(C))
n = get(io, :label, "")
_show_semi_compact(io, C, cov, n)
elseif get(io, :supercompact, false)
elseif is_terse(io)
print(io, "Cartier divisor")
elseif has_attribute(C, :name)
print(io, get_attribute(C, :name))
Expand Down
4 changes: 2 additions & 2 deletions experimental/Schemes/CoherentSheaves.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ end

function Base.show(io::IO, M::AbsCoherentSheaf)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Coherent sheaf of modules")
elseif has_attribute(M, :name)
print(io, get_attribute(M, :name))
Expand Down Expand Up @@ -1009,7 +1009,7 @@ function direct_sum(summands::Vector{<:AbsCoherentSheaf})
end

function Base.show(io::IO, M::DirectSumSheaf)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Direct sum of sheaves")
else
s = summands(M)
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/CoveredProjectiveSchemes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function Base.show(io::IO, CPS::CoveredProjectiveScheme)
io = pretty(io)
n = length(projective_patches(CPS))
K = base_ring(base_scheme(CPS))
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Relative projective scheme")
else
if length(projective_patches(CPS)) == 0
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/CoveredScheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ end
########################################################################
function Base.show(io::IO, f::CompositeCoveredSchemeMorphism)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Composite morphism")
else
print(io, "Composition of ", "$(domain(f)) -> ")
Expand Down
4 changes: 2 additions & 2 deletions experimental/Schemes/FunctionFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ canonical_unit(f::VarietyFunctionFieldElem) = f # part of the ring interface tha

function Base.show(io::IO, KK::VarietyFunctionField)
io = pretty(io)
if get(io, :supercompact, false)
if is_terse(io)
print(io, "Field of rational functions")
else
print(io, "Field of rational functions on ", Lowercase(), variety(KK))
Expand Down Expand Up @@ -415,7 +415,7 @@ function Base.show(io::IO, f::VarietyFunctionFieldElem)
cov = Oscar._covering_for_printing(io, X)
k = get(io, :offset, 0)
_show_semi_compact(io, f, cov, k)
elseif get(io, :supercompact, false)
elseif is_terse(io)
print(io, "Rational function")
else
print(io, "Rational function on ", Lowercase(), variety(parent(f)))
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/IdealSheaves.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ function Base.show(io::IO, I::AbsIdealSheaf)
prim = get_attribute(I, :is_prime, false)
if has_attribute(I, :name)
print(io, get_attribute(I, :name))
elseif get(io, :supercompact, false)
elseif is_terse(io)
print(io, "Sheaf of ideals")
else
if get_attribute(I, :is_one, false)
Expand Down
2 changes: 1 addition & 1 deletion experimental/Schemes/MorphismFromRationalFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ morphism_from_rational_functions(
) = MorphismFromRationalFunctions(X, Y, U, V, a; check, domain_covering, codomain_covering)

function Base.show(io::IOContext, Phi::MorphismFromRationalFunctions)
if get(io, :supercompact, false)
if is_terse(io)
print("Morphism from rational functions")
else
io = pretty(io)
Expand Down
Loading

0 comments on commit ccfb47f

Please sign in to comment.