Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dedicated printing for empty combinatorial objects #4236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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

Check warning on line 46 in src/Combinatorics/EnumerativeCombinatorics/compositions.jl

View check run for this annotation

Codecov / codecov/patch

src/Combinatorics/EnumerativeCombinatorics/compositions.jl#L45-L46

Added lines #L45 - L46 were not covered by tests
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 @@
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

Check warning on line 78 in src/Combinatorics/EnumerativeCombinatorics/partitions.jl

View check run for this annotation

Codecov / codecov/patch

src/Combinatorics/EnumerativeCombinatorics/partitions.jl#L77-L78

Added lines #L77 - L78 were not covered by tests
end
print(io, p)
end

################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
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

Check warning on line 38 in src/Combinatorics/EnumerativeCombinatorics/weak_compositions.jl

View check run for this annotation

Codecov / codecov/patch

src/Combinatorics/EnumerativeCombinatorics/weak_compositions.jl#L37-L38

Added lines #L37 - L38 were not covered by tests
end
print(io, c)
end

################################################################################
Expand Down
Loading