From a42adb69876110930e8d5f609185d1749d87ab24 Mon Sep 17 00:00:00 2001 From: "user.email" Date: Thu, 30 Jun 2022 17:08:44 -0400 Subject: [PATCH 1/4] Simplify printing of Term(identity, x) --- src/types.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types.jl b/src/types.jl index 350c0efcd..66890453e 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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) + show(io, args[1]) else show_call(io, f, args) end From 57f06e13f941ed7cb72758697e5100aadef122c9 Mon Sep 17 00:00:00 2001 From: Mike Boyle Date: Mon, 1 Aug 2022 17:00:48 +0000 Subject: [PATCH 2/4] Ensure argument to identity is not sym or tree --- src/types.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.jl b/src/types.jl index 66890453e..754591488 100644 --- a/src/types.jl +++ b/src/types.jl @@ -845,7 +845,7 @@ function show_term(io::IO, t) show_pow(io, args) elseif f === (getindex) show_ref(io, f, args) - elseif f === (identity) + elseif f === (identity) && !issym(args[1]) && !istree(args[1]] show(io, args[1]) else show_call(io, f, args) From 6e60da7698077935739cbebaae39bd5fc58ebebd Mon Sep 17 00:00:00 2001 From: "user.email" Date: Mon, 1 Aug 2022 13:06:59 -0400 Subject: [PATCH 3/4] Fix typo --- src/types.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.jl b/src/types.jl index 754591488..1b6647727 100644 --- a/src/types.jl +++ b/src/types.jl @@ -845,7 +845,7 @@ 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]] + elseif f === (identity) && !issym(args[1]) && !istree(args[1]) show(io, args[1]) else show_call(io, f, args) From 56fd3b9735f729fae3e1fc9dad7a13dc886c720f Mon Sep 17 00:00:00 2001 From: "user.email" Date: Mon, 1 Aug 2022 14:10:43 -0400 Subject: [PATCH 4/4] Test show_term for identity(::Irrational) --- test/code.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/code.jl b/test/code.jl index 31290e67e..5a10ca0c2 100644 --- a/test/code.jl +++ b/test/code.jl @@ -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