Skip to content

Commit dcbe861

Browse files
authored
Merge pull request #450 from moble/master
Simplify printing of Term(identity, x)
2 parents 97a8a86 + 56fd3b9 commit dcbe861

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/types.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ function show_term(io::IO, t)
845845
show_pow(io, args)
846846
elseif f === (getindex)
847847
show_ref(io, f, args)
848+
elseif f === (identity) && !issym(args[1]) && !istree(args[1])
849+
show(io, args[1])
848850
else
849851
show_call(io, f, args)
850852
end

test/code.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,16 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen
190190
@test f(1) == 1
191191
@test f(2) == 2
192192
end
193+
194+
let
195+
io = IOBuffer()
196+
twoπ = Base.Irrational{:twoπ}()
197+
for q Base.Irrational[Base.MathConstants.catalan, Base.MathConstants.γ, π, Base.MathConstants.φ, ℯ, twoπ]
198+
Base.show(io, q)
199+
s1 = String(take!(io))
200+
SymbolicUtils.show_term(io, SymbolicUtils.Term(identity, [q]))
201+
s2 = String(take!(io))
202+
@test s1 == s2
203+
end
204+
end
193205
end

0 commit comments

Comments
 (0)