Skip to content

Commit

Permalink
Merge pull request #450 from moble/master
Browse files Browse the repository at this point in the history
Simplify printing of Term(identity, x)
  • Loading branch information
shashi authored Aug 23, 2022
2 parents 97a8a86 + 56fd3b9 commit dcbe861
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ function show_term(io::IO, t)
show_pow(io, args)
elseif f === (getindex)
show_ref(io, f, args)
elseif f === (identity) && !issym(args[1]) && !istree(args[1])
show(io, args[1])
else
show_call(io, f, args)
end
Expand Down
12 changes: 12 additions & 0 deletions test/code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,16 @@ test_repr(a, b) = @test repr(Base.remove_linenums!(a)) == repr(Base.remove_linen
@test f(1) == 1
@test f(2) == 2
end

let
io = IOBuffer()
twoπ = Base.Irrational{:twoπ}()
for q Base.Irrational[Base.MathConstants.catalan, Base.MathConstants.γ, π, Base.MathConstants.φ, ℯ, twoπ]
Base.show(io, q)
s1 = String(take!(io))
SymbolicUtils.show_term(io, SymbolicUtils.Term(identity, [q]))
s2 = String(take!(io))
@test s1 == s2
end
end
end

0 comments on commit dcbe861

Please sign in to comment.