comparison test/Grids/equidistant_grid_test.jl @ 1480:4550beef9694 feature/boundary_conditions

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sat, 23 Dec 2023 23:03:13 +0100
parents 37cf9f79caa4
children 43aaf710463e
comparison
equal deleted inserted replaced
1479:b96858a50e35 1480:4550beef9694
28 @test eltype(EquidistantGrid(0:10)) == Int 28 @test eltype(EquidistantGrid(0:10)) == Int
29 @test eltype(EquidistantGrid(0:2:10)) == Int 29 @test eltype(EquidistantGrid(0:2:10)) == Int
30 @test eltype(EquidistantGrid(0:0.1:10)) == Float64 30 @test eltype(EquidistantGrid(0:0.1:10)) == Float64
31 @test size(EquidistantGrid(0:10)) == (11,) 31 @test size(EquidistantGrid(0:10)) == (11,)
32 @test size(EquidistantGrid(0:0.1:10)) == (101,) 32 @test size(EquidistantGrid(0:0.1:10)) == (101,)
33
34 @test size(EquidistantGrid(0:0.1:10),1) == 101
33 35
34 @test collect(EquidistantGrid(0:0.1:0.5)) == [0.0, 0.1, 0.2, 0.3, 0.4, 0.5] 36 @test collect(EquidistantGrid(0:0.1:0.5)) == [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
35 37
36 @test Base.IteratorSize(EquidistantGrid{Float64, StepRange{Float64}}) == Base.HasShape{1}() 38 @test Base.IteratorSize(EquidistantGrid{Float64, StepRange{Float64}}) == Base.HasShape{1}()
37 end 39 end
62 64
63 @testset "boundary_grid" begin 65 @testset "boundary_grid" begin
64 g = EquidistantGrid(0:0.1:1) 66 g = EquidistantGrid(0:0.1:1)
65 @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0) 67 @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0)
66 @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0) 68 @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0)
69 end
70
71 @testset "boundary_indices" begin
72 g = EquidistantGrid(0:0.1:1)
73 @test boundary_indices(g, Lower()) == (1,)
74 @test boundary_indices(g, Upper()) == (11,)
75
76 g = EquidistantGrid(2:0.1:10)
77 @test boundary_indices(g, Lower()) == (1,)
78 @test boundary_indices(g, Upper()) == (81,)
79
67 end 80 end
68 81
69 @testset "refine" begin 82 @testset "refine" begin
70 g = EquidistantGrid(0:0.1:1) 83 g = EquidistantGrid(0:0.1:1)
71 @test refine(g, 1) == g 84 @test refine(g, 1) == g
105 @test_throws DomainError equidistant_grid((1,1),(1.0,1.0),(-1.0,-1.0)) 118 @test_throws DomainError equidistant_grid((1,1),(1.0,1.0),(-1.0,-1.0))
106 119
107 @testset "Base" begin 120 @testset "Base" begin
108 @test eltype(equidistant_grid(4,0.0,1.0)) == Float64 121 @test eltype(equidistant_grid(4,0.0,1.0)) == Float64
109 @test eltype(equidistant_grid((4,3),(0,0),(1,3))) <: AbstractVector{Float64} 122 @test eltype(equidistant_grid((4,3),(0,0),(1,3))) <: AbstractVector{Float64}
123
110 @test size(equidistant_grid(4,0.0,1.0)) == (4,) 124 @test size(equidistant_grid(4,0.0,1.0)) == (4,)
111 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3) 125 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3)
126
127 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0)),1) == 5
128 @test size(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0)),2) == 3
129
112 @test ndims(equidistant_grid(4,0.0,1.0)) == 1 130 @test ndims(equidistant_grid(4,0.0,1.0)) == 1
113 @test ndims(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == 2 131 @test ndims(equidistant_grid((5,3), (0.0,0.0), (2.0,1.0))) == 2
114 end 132 end
115 133
116 @testset "getindex" begin 134 @testset "getindex" begin