Skip to content

Commit

Permalink
Merge pull request #296 from JuliaSymbolics/myb/print
Browse files Browse the repository at this point in the history
Add show_type option in print_tree
  • Loading branch information
shashi authored Jun 10, 2021
2 parents 6bae4bd + 133ee3b commit 6d22c51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ end
AbstractTrees.children(x::Union{Pow}) = [x.base, x.exp]
AbstractTrees.children(x::TreePrint) = [x.x[1], x.x[2]]

print_tree(x; maxdepth=Inf, kw...) = print_tree(stdout, x; maxdepth=maxdepth, kw...)
function print_tree(_io::IO, x::Union{Term, Add, Mul, Pow}; kw...)
print_tree(x; show_type=false, maxdepth=Inf, kw...) = print_tree(stdout, x; show_type=show_type, maxdepth=maxdepth, kw...)
function print_tree(_io::IO, x::Union{Term, Add, Mul, Pow}; show_type=false, kw...)
AbstractTrees.print_tree(_io, x; withinds=true, kw...) do io, y, inds
if istree(y)
print(io, operation(y))
Expand All @@ -1001,5 +1001,8 @@ function print_tree(_io::IO, x::Union{Term, Add, Mul, Pow}; kw...)
else
print(io, y)
end
if !(y isa TreePrint) && show_type
print(io, " [", typeof(y), "]")
end
end
end
14 changes: 7 additions & 7 deletions test/fuzz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ using Random: seed!

seed!(6174)
@testset "Fuzz test" begin
@testset "expand fuzz" begin
@time @testset "expand fuzz" begin
for i=1:500
fuzz_test(5, num_spec, SymbolicUtils.expand; min_depth=3)
end
end
@testset "num fuzz" begin
@time @testset "num fuzz" begin
for i=1:1500
fuzz_test(5, num_spec)
end
end
@testset "bool fuzz" begin
@time @testset "bool fuzz" begin
for i=1:500
seed!(i)
fuzz_test(5, bool_spec)
end
end
@testset "fuzz addmulpow" begin
for i=1:100;
@time for i=1:100
fuzz_addmulpow(1)
end
for i=1:50;
@time for i=1:50
fuzz_addmulpow(2)
end
for i=1:25;
@time for i=1:25
fuzz_addmulpow(3)
end
for i=1:12;
@time for i=1:12
fuzz_addmulpow(4)
end
end
Expand Down

0 comments on commit 6d22c51

Please sign in to comment.