Skip to content

Commit 7c3a407

Browse files
committed
Add show_type option in print_tree
1 parent 3d78a70 commit 7c3a407

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/types.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,8 @@ end
991991
AbstractTrees.children(x::Union{Pow}) = [x.base, x.exp]
992992
AbstractTrees.children(x::TreePrint) = [x.x[1], x.x[2]]
993993

994-
print_tree(x; maxdepth=Inf, kw...) = print_tree(stdout, x; maxdepth=maxdepth, kw...)
995-
function print_tree(_io::IO, x::Union{Term, Add, Mul, Pow}; kw...)
994+
print_tree(x; show_type=false, maxdepth=Inf, kw...) = print_tree(stdout, x; show_type=show_type, maxdepth=maxdepth, kw...)
995+
function print_tree(_io::IO, x::Union{Term, Add, Mul, Pow}; show_type=false, kw...)
996996
AbstractTrees.print_tree(_io, x; withinds=true, kw...) do io, y, inds
997997
if istree(y)
998998
print(io, operation(y))
@@ -1001,5 +1001,8 @@ function print_tree(_io::IO, x::Union{Term, Add, Mul, Pow}; kw...)
10011001
else
10021002
print(io, y)
10031003
end
1004+
if !(y isa TreePrint) && show_type
1005+
print(io, " [", typeof(y), "]")
1006+
end
10041007
end
10051008
end

0 commit comments

Comments
 (0)