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

Simplify printing of Term(identity, x) #450

Merged
merged 4 commits into from
Aug 23, 2022
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
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