comparison test/Grids/tensor_grid_test.jl @ 1825:98ae79eb0709 refactor/grids/iterable_boundary_indices

Refine tests
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 17 Sep 2024 09:12:36 +0200
parents 7a2375080287
children ab397590898e
comparison
equal deleted inserted replaced
1824:7a2375080287 1825:98ae79eb0709
173 @testset "boundary_indices" begin 173 @testset "boundary_indices" begin
174 g₁ = EquidistantGrid(range(0,1,length=11)) 174 g₁ = EquidistantGrid(range(0,1,length=11))
175 g₂ = EquidistantGrid(range(2,3,length=6)) 175 g₂ = EquidistantGrid(range(2,3,length=6))
176 g₄ = ZeroDimGrid(@SVector[1,2]) 176 g₄ = ZeroDimGrid(@SVector[1,2])
177 177
178 @test iterate(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}()))
179
180 gf = reshape(1:(11*6),11,6) 178 gf = reshape(1:(11*6),11,6)
181 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}()))] == gf[1,:] 179 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}())] == gf[1,:]
182 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()))] == gf[11,:] 180 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}())] == gf[11,:]
183 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}()))] == gf[:,1] 181 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}())] == gf[:,1]
184 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}()))] == gf[:,6] 182 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}())] == gf[:,6]
185 183
186 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}())) == [(1,i) for i ∈ 1:6] 184 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}())) == [CartesianIndex(1,i) for i ∈ 1:6]
187 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}())) == [(11,i) for i ∈ 1:6] 185 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}())) == [CartesianIndex(11,i) for i ∈ 1:6]
188 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}())) == [(i,1) for i ∈ 1:11] 186 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}())) == [CartesianIndex(i,1) for i ∈ 1:11]
189 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}())) == [(i,6) for i ∈ 1:11] 187 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}())) == [CartesianIndex(i,6) for i ∈ 1:11]
190 @test collect(boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Lower}())) == [(1,)] 188 @test collect(boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Lower}())) == 1
191 @test collect(boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}())) == [(11,)] 189 @test collect(boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}())) == 11
192 @test collect(boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Lower}())) == [(1,)] 190 @test collect(boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Lower}())) == 1
193 @test collect(boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Upper}())) == [(11,)] 191 @test collect(boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Upper}())) == 11
194 end 192 end
195 end 193 end
196 194
197 @testset "combined_coordinate_vector_type" begin 195 @testset "combined_coordinate_vector_type" begin
198 @test Grids.combined_coordinate_vector_type(Float64) == Float64 196 @test Grids.combined_coordinate_vector_type(Float64) == Float64