Skip to content

Commit

Permalink
Add dedicated printing for empty combinatorial objects (#4236)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Oct 24, 2024
1 parent 31ca31b commit ab11326
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Combinatorics/EnumerativeCombinatorics/compositions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ function composition(parts::Vector{T}; check::Bool = true) where {T <: IntegerUn
end

function Base.show(io::IO, ::MIME"text/plain", C::Composition)
print(io, data(C))
c = data(C)
if isempty(c)
print(io, "Empty composition")
return
end
print(io, c)
end

################################################################################
Expand Down
7 changes: 6 additions & 1 deletion src/Combinatorics/EnumerativeCombinatorics/partitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ end
data(P::Partition) = P.p

function Base.show(io::IO, ::MIME"text/plain", P::Partition)
print(io, data(P))
p = data(P)
if isempty(p)
print(io, "Empty partition")
return
end
print(io, p)
end

################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ function weak_composition(parts::Vector{T}; check::Bool = true) where {T <: Inte
end

function Base.show(io::IO, ::MIME"text/plain", C::WeakComposition)
print(io, data(C))
c = data(C)
if isempty(c)
print(io, "Empty weak composition")
return
end
print(io, c)
end

################################################################################
Expand Down

0 comments on commit ab11326

Please sign in to comment.