changeset 389:0433ab553d13 refactor/sbp_operators_tests/collect_and_compare

Rewrite l2 norm comparison to use the norm key word of isapprox
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 01 Oct 2020 08:23:22 +0200
parents 5223872485cd
children 737e597e0e6d
files test/testSbpOperators.jl
diffstat 1 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
diff -r 5223872485cd -r 0433ab553d13 test/testSbpOperators.jl
--- a/test/testSbpOperators.jl	Thu Oct 01 08:16:46 2020 +0200
+++ b/test/testSbpOperators.jl	Thu Oct 01 08:23:22 2020 +0200
@@ -65,11 +65,10 @@
     @test Dₓₓ*v2 ≈ v0 atol=5e-11
     @test Dₓₓ*v3 ≈ v1 atol=5e-11
 
-    e4 = Dₓₓ*v4 - v2
-    e5 = Dₓₓ*v5 + v5
     h = spacing(g)[1];
-    @test sqrt(h*sum(e4.^2)) ≈ 0 atol=5e-4
-    @test sqrt(h*sum(e5.^2)) ≈ 0 atol=5e-4
+    l2(v) = sqrt(h*sum(v.^2))
+    @test Dₓₓ*v4 ≈ v2  atol=5e-4 norm=l2
+    @test Dₓₓ*v5 ≈ -v5 atol=5e-4 norm=l2
 end
 
 
@@ -108,12 +107,11 @@
     @test_broken L*v1 ≈ 0 atol=5e-11
     @test L*v2 ≈ v0 # Seems to be more accurate
     @test L*v3 ≈ v1 atol=5e-10
-    e4 = L*v4 - v2
-    e5 = L*v5 - v5ₓₓ
 
     h = spacing(g)
-    @test sqrt(prod(h)*sum(e4.^2)) ≈ 0 atol=5e-4
-    @test sqrt(prod(h)*sum(e5.^2)) ≈ 0 atol=5e-4
+    l2(v) = sqrt(prod(h)*sum(v.^2))
+    @test L*v4 ≈ v2   atol=5e-4 norm=l2
+    @test L*v5 ≈ v5ₓₓ atol=5e-4 norm=l2
 end
 
 @testset "DiagonalInnerProduct" begin