Mercurial > repos > public > sbplib_julia
comparison test/testGrids.jl @ 409:b4e65cb18423
Merge test/equidistantgrid
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 13 Oct 2020 18:33:43 +0200 |
parents | b7734413003d |
children | b21fea54ca10 |
comparison
equal
deleted
inserted
replaced
404:48d57f185f86 | 409:b4e65cb18423 |
---|---|
4 @testset "Grids" begin | 4 @testset "Grids" begin |
5 | 5 |
6 @testset "EquidistantGrid" begin | 6 @testset "EquidistantGrid" begin |
7 @test EquidistantGrid(4,0.0,1.0) isa EquidistantGrid | 7 @test EquidistantGrid(4,0.0,1.0) isa EquidistantGrid |
8 @test EquidistantGrid(4,0.0,8.0) isa EquidistantGrid | 8 @test EquidistantGrid(4,0.0,8.0) isa EquidistantGrid |
9 @test dimension(EquidistantGrid(4,0.0,1.0)) == 1 | 9 # constuctor |
10 @test_throws DomainError EquidistantGrid(0,0.0,1.0) | |
11 @test_throws DomainError EquidistantGrid(1,1.0,1.0) | |
12 @test_throws DomainError EquidistantGrid(1,1.0,-1.0) | |
10 @test EquidistantGrid(4,0.0,1.0) == EquidistantGrid((4,),(0.0,),(1.0,)) | 13 @test EquidistantGrid(4,0.0,1.0) == EquidistantGrid((4,),(0.0,),(1.0,)) |
11 | 14 |
15 # size | |
16 @test size(EquidistantGrid(4,0.0,1.0)) == (4,) | |
17 @test size(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3) | |
18 | |
19 # dimension | |
20 @test dimension(EquidistantGrid(4,0.0,1.0)) == 1 | |
21 @test dimension(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == 2 | |
22 | |
23 # spacing | |
24 @test [spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(1. /3,)...] atol=5e-13 | |
25 @test [spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(0.5, 1.)...] atol=5e-13 | |
26 | |
27 # inverse_spacing | |
28 @test [inverse_spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(3.,)...] atol=5e-13 | |
29 @test [inverse_spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(2, 1.)...] atol=5e-13 | |
30 | |
31 # points | |
32 g = EquidistantGrid((5,3), (-1.0,0.0), (0.0,7.11)) | |
33 gp = points(g); | |
34 p = [(-1.,0.) (-1.,7.11/2) (-1.,7.11); | |
35 (-0.75,0.) (-0.75,7.11/2) (-0.75,7.11); | |
36 (-0.5,0.) (-0.5,7.11/2) (-0.5,7.11); | |
37 (-0.25,0.) (-0.25,7.11/2) (-0.25,7.11); | |
38 (0.,0.) (0.,7.11/2) (0.,7.11)] | |
39 for i ∈ eachindex(gp) | |
40 @test [gp[i]...] ≈ [p[i]...] atol=5e-13 | |
41 end | |
42 | |
43 # restrict | |
12 g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0)) | 44 g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0)) |
13 @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0) | 45 @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0) |
14 @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0) | 46 @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0) |
15 | 47 |
16 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0)) | 48 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0)) |