comparison test/Grids/tensor_grid_test.jl @ 1874:610ac5ca5d43 feature/documenter_logo

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 27 Jan 2025 09:23:01 +0100
parents fa96b57af6a1
children
comparison
equal deleted inserted replaced
1862:2c63ebc38b79 1874:610ac5ca5d43
202 @testset "boundary_indices" begin 202 @testset "boundary_indices" begin
203 g₁ = EquidistantGrid(range(0,1,length=11)) 203 g₁ = EquidistantGrid(range(0,1,length=11))
204 g₂ = EquidistantGrid(range(2,3,length=6)) 204 g₂ = EquidistantGrid(range(2,3,length=6))
205 g₄ = ZeroDimGrid(@SVector[1,2]) 205 g₄ = ZeroDimGrid(@SVector[1,2])
206 206
207 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, LowerBoundary}()) == (1,:) 207 gf = reshape(1:(11*6),11,6)
208 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}()) == (11,:) 208 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, LowerBoundary}())] == gf[1,:]
209 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, LowerBoundary}()) == (:,1) 209 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}())] == gf[11,:]
210 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, UpperBoundary}()) == (:,6) 210 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, LowerBoundary}())] == gf[:,1]
211 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, LowerBoundary}()) == (1,) 211 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, UpperBoundary}())] == gf[:,6]
212 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, UpperBoundary}()) == (11,) 212
213 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, LowerBoundary}()) == (1,) 213 gf = rand(11)
214 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, UpperBoundary}()) == (11,) 214 @test gf[boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, LowerBoundary}())] == gf[1]
215 @test gf[boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, UpperBoundary}())] == gf[11]
216 @test gf[boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, LowerBoundary}())] == gf[1]
217 @test gf[boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, UpperBoundary}())] == gf[11]
218
219 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, LowerBoundary}())) == [CartesianIndex(1,i) for i ∈ 1:6]
220 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}())) == [CartesianIndex(11,i) for i ∈ 1:6]
221 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, LowerBoundary}())) == [CartesianIndex(i,1) for i ∈ 1:11]
222 @test collect(boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, UpperBoundary}())) == [CartesianIndex(i,6) for i ∈ 1:11]
223 @test collect(boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, LowerBoundary}())) == fill(1)
224 @test collect(boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, UpperBoundary}())) == fill(11)
225 @test collect(boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, LowerBoundary}())) == fill(1)
226 @test collect(boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, UpperBoundary}())) == fill(11)
215 end 227 end
216 end 228 end
217 229
218 @testset "combined_coordinate_vector_type" begin 230 @testset "combined_coordinate_vector_type" begin
219 @test Grids.combined_coordinate_vector_type(Float64) == Float64 231 @test Grids.combined_coordinate_vector_type(Float64) == Float64