From 478cd2d698d8945b2438d755f0869608f7a531e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poisot?= Date: Fri, 11 Feb 2022 14:01:49 -0500 Subject: [PATCH] fix the omnivory test --- test/community/foodwebs.jl | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/test/community/foodwebs.jl b/test/community/foodwebs.jl index dd511510..836e0783 100644 --- a/test/community/foodwebs.jl +++ b/test/community/foodwebs.jl @@ -1,19 +1,26 @@ module TestFoodWebs - using Test - using EcologicalNetworks +using Test +using EcologicalNetworks - # test trophic levels on motifs - s1 = unipartitemotifs()[:S1] - s1_ftl = trophic_level(s1) - s1_tl = distance_to_producer(s1) - @test maximum(values(s1_ftl)) ≈ 3 - @test maximum(values(s1_tl)) ≈ 3.0 - @test s1_ftl[:a] ≈ 3 - @test s1_ftl[:b] ≈ 2 - @test s1_ftl[:c] ≈ 1 +# test trophic levels on motifs +s1 = unipartitemotifs()[:S1] +s1_ftl = trophic_level(s1) +s1_tl = distance_to_producer(s1) +@test maximum(values(s1_ftl)) ≈ 3 +@test maximum(values(s1_tl)) ≈ 3.0 +@test s1_ftl[:a] ≈ 3 +@test s1_ftl[:b] ≈ 2 +@test s1_ftl[:c] ≈ 1 - s2 = unipartitemotifs()[:S2] - @test minimum(values(trophic_level(s1))) ≈ 1.0 - @test minimum(values(distance_to_producer(s1))) == 1.0 +s2 = unipartitemotifs()[:S2] +@test minimum(values(trophic_level(s1))) ≈ 1.0 +@test minimum(values(distance_to_producer(s1))) == 1.0 + +# Test for omnivory +for s in species(s1) + if iszero(EcologicalNetworks.degree_out(s1)[s]) + @test iszero(omnivory(s1)[s]) + end +end end