From 091f38a4547c3249cdcb0a163a460f6034d8ba0e Mon Sep 17 00:00:00 2001 From: Art Wild Date: Sat, 19 Mar 2022 16:55:44 -0400 Subject: [PATCH] relax test tolerance --- test/gp.jl | 27 ++++++++++++++------------- test/mutations.jl | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/test/gp.jl b/test/gp.jl index fd9f6e3..5e28ab2 100644 --- a/test/gp.jl +++ b/test/gp.jl @@ -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 diff --git a/test/mutations.jl b/test/mutations.jl index 7013914..da3eb43 100644 --- a/test/mutations.jl +++ b/test/mutations.jl @@ -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