Skip to content

Commit 6d22c51

Browse files
authored
Merge pull request #296 from JuliaSymbolics/myb/print
Add show_type option in print_tree
2 parents 6bae4bd + 133ee3b commit 6d22c51

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
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

test/fuzz.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ using Random: seed!
44

55
seed!(6174)
66
@testset "Fuzz test" begin
7-
@testset "expand fuzz" begin
7+
@time @testset "expand fuzz" begin
88
for i=1:500
99
fuzz_test(5, num_spec, SymbolicUtils.expand; min_depth=3)
1010
end
1111
end
12-
@testset "num fuzz" begin
12+
@time @testset "num fuzz" begin
1313
for i=1:1500
1414
fuzz_test(5, num_spec)
1515
end
1616
end
17-
@testset "bool fuzz" begin
17+
@time @testset "bool fuzz" begin
1818
for i=1:500
1919
seed!(i)
2020
fuzz_test(5, bool_spec)
2121
end
2222
end
2323
@testset "fuzz addmulpow" begin
24-
for i=1:100;
24+
@time for i=1:100
2525
fuzz_addmulpow(1)
2626
end
27-
for i=1:50;
27+
@time for i=1:50
2828
fuzz_addmulpow(2)
2929
end
30-
for i=1:25;
30+
@time for i=1:25
3131
fuzz_addmulpow(3)
3232
end
33-
for i=1:12;
33+
@time for i=1:12
3434
fuzz_addmulpow(4)
3535
end
3636
end

0 commit comments

Comments
 (0)