Mercurial > repos > public > sbplib_julia
annotate test/SbpOperators/stencil_test.jl @ 993:2f9beee56a4c refactor/lazy_tensors
Use ScalingTensor instead of custom test type
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 18 Mar 2022 20:41:31 +0100 |
parents | 4433be383840 |
children | 313648b01504 11767fbb29f4 |
rev | line source |
---|---|
728
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
1 using Test |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
2 using Sbplib.SbpOperators |
732
6114274447f5
Add missing using and imports in test files
Jonatan Werpers <jonatan@werpers.com>
parents:
728
diff
changeset
|
3 import Sbplib.SbpOperators.Stencil |
728
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
4 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
5 @testset "Stencil" begin |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
6 s = Stencil((-2,2), (1.,2.,2.,3.,4.)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
7 @test s isa Stencil{Float64, 5} |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
8 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
9 @test eltype(s) == Float64 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
10 @test SbpOperators.scale(s, 2) == Stencil((-2,2), (2.,4.,4.,6.,8.)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
11 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
12 @test Stencil(1,2,3,4; center=1) == Stencil((0, 3),(1,2,3,4)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
13 @test Stencil(1,2,3,4; center=2) == Stencil((-1, 2),(1,2,3,4)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
14 @test Stencil(1,2,3,4; center=4) == Stencil((-3, 0),(1,2,3,4)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
15 |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
16 @test CenteredStencil(1,2,3,4,5) == Stencil((-2, 2), (1,2,3,4,5)) |
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
17 @test_throws ArgumentError CenteredStencil(1,2,3,4) |
826
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
18 |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
19 # Changing the type of the weights |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
20 @test Stencil{Float64}(Stencil(1,2,3,4,5; center=2)) == Stencil(1.,2.,3.,4.,5.; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
21 @test Stencil{Float64}(CenteredStencil(1,2,3,4,5)) == CenteredStencil(1.,2.,3.,4.,5.) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
22 @test Stencil{Int}(Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1,2,3,4,5; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
23 @test Stencil{Rational}(Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1//1,2//1,3//1,4//1,5//1; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
24 |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
25 @testset "convert" begin |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
26 @test convert(Stencil{Float64}, Stencil(1,2,3,4,5; center=2)) == Stencil(1.,2.,3.,4.,5.; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
27 @test convert(Stencil{Float64}, CenteredStencil(1,2,3,4,5)) == CenteredStencil(1.,2.,3.,4.,5.) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
28 @test convert(Stencil{Int}, Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1,2,3,4,5; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
29 @test convert(Stencil{Rational}, Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1//1,2//1,3//1,4//1,5//1; center=2) |
4433be383840
Add stencil constructor to change the type of the weights along with a convert method
Jonatan Werpers <jonatan@werpers.com>
parents:
732
diff
changeset
|
30 end |
728
45966c77cb20
Split tests for SbpOperators over several files
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
31 end |