diff --git a/test/measures/test-functioning.jl b/test/measures/test-functioning.jl index 56d4733e4..f612b5d35 100644 --- a/test/measures/test-functioning.jl +++ b/test/measures/test-functioning.jl @@ -46,8 +46,8 @@ end sim_zero = simulates(params, [0, 0]; verbose = false) # Total biomass should converge to K - @test biomass(sim_one_sp; last = 1).total ≈ - get_parameters(sim_one_sp).environment.K[2] rtol = 0.001 + @test biomass(sim_one_sp; last = 1).total ≈ get_parameters(sim_one_sp).environment.K[2] rtol = + 0.001 # Species sub selection works @test biomass(sim_one_sp; last = 1, idxs = [1]).sp[1] ≈ @@ -73,13 +73,22 @@ end # Other hill diversity numbers ## Shannon @test shannon_diversity(sim_two_sp[:, end]) == - shannon_diversity(sim_two_sp; last = 1) == log(2) + shannon_diversity(sim_two_sp; last = 1) == + log(2) @test shannon_diversity(sim_one_sp[:, end]) == - shannon_diversity(sim_one_sp; last = 1) ≈ 0.0 # 0 entropy if 1 species only + shannon_diversity(sim_one_sp; last = 1) ≈ + 0.0 # 0 entropy if 1 species only @test isnan(shannon_diversity(sim_zero[:, end])) == - isnan(shannon_diversity(sim_zero; last = 1)) # Not defined for 0 species + isnan(shannon_diversity(sim_zero; last = 1)) # Not defined for 0 species + + @test shannon_diversity(sim_one_sp[:, end]) == + shannon_diversity(sim_one_sp; last = 1) ≈ + 0.0 # 0 entropy if 1 species only + + @test isnan(shannon_diversity(sim_zero[:, end])) == + isnan(shannon_diversity(sim_zero; last = 1)) # Not defined for 0 species ## Simpson @test simpson(sim_two_sp[:, end]) == @@ -87,16 +96,13 @@ end 1 / sum(2 .^ [1 / 2, 1 / 2]) @test simpson(sim_one_sp[:, end]) == simpson(sim_one_sp; last = 1) == - 1 / sum(2 .^ 1) == 0.5# 0.5 if 1 species only - @test isnan(simpson(sim_zero[:, end])) == - isnan(simpson(sim_zero; last = 1)) # Not defined for 0 species + 1 / sum(2 .^ 1) == + 0.5# 0.5 if 1 species only + @test isnan(simpson(sim_zero[:, end])) == isnan(simpson(sim_zero; last = 1)) # Not defined for 0 species # Community evenness - @test evenness(sim_two_sp[:, end]) == - evenness(sim_two_sp; last = 1) ≈ 1.0 # Maximum equity of species biomass - @test isnan(evenness(sim_one_sp[:, end])) == - isnan(evenness(sim_one_sp; last = 1))# Should be NaN if 1 species - @test isnan(evenness(sim_zero[:, end])) == - isnan(evenness(sim_zero; last = 1))# Should be NaN if 0 species + @test evenness(sim_two_sp[:, end]) == evenness(sim_two_sp; last = 1) ≈ 1.0 # Maximum equity of species biomass + @test isnan(evenness(sim_one_sp[:, end])) == isnan(evenness(sim_one_sp; last = 1))# Should be NaN if 1 species + @test isnan(evenness(sim_zero[:, end])) == isnan(evenness(sim_zero; last = 1))# Should be NaN if 0 species end