Skip to content

Commit

Permalink
relax test tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
wildart committed Mar 19, 2022
1 parent 96bf096 commit 091f38a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 14 additions & 13 deletions test/gp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@
@test popexp[1] == :(x + 1)

# recursive helper functions
h = 4
gtr = TreeGP(pop, terms, funcs, maxdepth=2, initialization=:grow)
Random.seed!(rng, 1)
tmp = rand(rng, gtr, 3)
Random.seed!(rng, 1)
gt = rand(rng, gtr, 3)
Random.seed!(rng, 8237463746)
tmp = rand(rng, gtr, h)
Random.seed!(rng, 8237463746)
gt = rand(rng, gtr, h)
@test tmp == gt
@test Evolutionary.nodes(gt) < 15
@test Evolutionary.height(gt) <= 3
@test length(gt) < 15
ft = rand(rng, TreeGP(pop, terms, funcs, maxdepth=2, initialization=:full), 3)
@test Evolutionary.nodes(ft) == 15
@test Evolutionary.height(ft) == 3
@test length(ft) == 15
@test Evolutionary.depth(ft, :x) == 3
@test Evolutionary.nodes(gt) < 2^(h+1)-1
@test Evolutionary.height(gt) <= h
@test length(gt) < 2^(h+1)-1
ft = rand(rng, TreeGP(pop, terms, funcs, maxdepth=2, initialization=:full), h)
@test Evolutionary.nodes(ft) == 2^(h+1)-1
@test Evolutionary.height(ft) == h
@test length(ft) == 2^(h+1)-1
@test Evolutionary.depth(ft, :x) == 4
ft[3] = :z
@test Evolutionary.depth(ft, :z) == 3
@test Evolutionary.depth(ft, :z) == 4
@test Evolutionary.depth(ft, ft) == 0
@test Evolutionary.depth(ft, ft[3]) > 0
@test Evolutionary.depth(ft, :w) == -1
Expand Down
4 changes: 2 additions & 2 deletions test/mutations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
end

# subtree mutation does not produce offspring expression longer then the parent
mut = subtree(tr; growth=0.5)
mut = subtree(tr; growth=0.3)
Random.seed!(rng, 2)
off = [mut(copy(ex), rng=rng) for i in 1:10]
@testset "Offspring Height (Growth)" for i in 1:5
map(o->mut(o,rng=rng), off) # mutate offspring
h = map(Evolutionary.height, off)
@test all(h .<= 3+i)
@test all(h .<= 3i)
end

# hoist
Expand Down

0 comments on commit 091f38a

Please sign in to comment.