Mercurial > repos > public > sbplib_julia
comparison test/Grids/tensor_grid_test.jl @ 1877:21e5fe1545c0 refactor/lazy_tensors/elementwise_ops
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 27 Jan 2025 16:56:04 +0100 |
parents | fa96b57af6a1 |
children |
comparison
equal
deleted
inserted
replaced
1840:cb3a8450ed44 | 1877:21e5fe1545c0 |
---|---|
135 @test axes(g, 1) == 1:11 | 135 @test axes(g, 1) == 1:11 |
136 @test axes(g, 2) == 1:6 | 136 @test axes(g, 2) == 1:6 |
137 @test axes(g) == (1:11,1:6) | 137 @test axes(g) == (1:11,1:6) |
138 end | 138 end |
139 | 139 |
140 @testset "spacing" begin | |
141 g₁ = EquidistantGrid(range(0,1,length=11)) | |
142 g₂ = EquidistantGrid(range(2,3,length=6)) | |
143 g₃ = ZeroDimGrid(@SVector[1,2]) | |
144 | |
145 @test spacing(TensorGrid(g₁)) == (1/10,) | |
146 @test spacing(TensorGrid(g₂)) == (1/5,) | |
147 | |
148 @test spacing(TensorGrid(g₁, g₂)) == (1/10, 1/5) | |
149 | |
150 @test spacing(TensorGrid(g₁, g₃)) == (1/10,) | |
151 @test spacing(TensorGrid(g₃, g₂)) == (1/5,) | |
152 | |
153 | |
154 @test spacing(TensorGrid(g₁, g₂, g₁)) == (1/10, 1/5, 1/10) | |
155 | |
156 @test spacing(TensorGrid(g₃, g₂, g₁)) == (1/5, 1/10) | |
157 @test spacing(TensorGrid(g₁, g₃, g₁)) == (1/10, 1/10) | |
158 @test spacing(TensorGrid(g₁, g₂, g₃)) == (1/10, 1/5) | |
159 end | |
160 | |
140 @testset "min_spacing" begin | 161 @testset "min_spacing" begin |
141 g₁ = EquidistantGrid(range(0,1,length=11)) | 162 g₁ = EquidistantGrid(range(0,1,length=11)) |
142 g₂ = EquidistantGrid(range(2,3,length=6)) | 163 g₂ = EquidistantGrid(range(2,3,length=6)) |
143 g₃ = ZeroDimGrid(@SVector[1,2]) | 164 g₃ = ZeroDimGrid(@SVector[1,2]) |
144 | 165 |
181 @testset "boundary_indices" begin | 202 @testset "boundary_indices" begin |
182 g₁ = EquidistantGrid(range(0,1,length=11)) | 203 g₁ = EquidistantGrid(range(0,1,length=11)) |
183 g₂ = EquidistantGrid(range(2,3,length=6)) | 204 g₂ = EquidistantGrid(range(2,3,length=6)) |
184 g₄ = ZeroDimGrid(@SVector[1,2]) | 205 g₄ = ZeroDimGrid(@SVector[1,2]) |
185 | 206 |
186 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, LowerBoundary}()) == (1,:) | 207 gf = reshape(1:(11*6),11,6) |
187 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}()) == (11,:) | 208 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, LowerBoundary}())] == gf[1,:] |
188 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, LowerBoundary}()) == (:,1) | 209 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}())] == gf[11,:] |
189 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, UpperBoundary}()) == (:,6) | 210 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, LowerBoundary}())] == gf[:,1] |
190 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, LowerBoundary}()) == (1,) | 211 @test gf[boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, UpperBoundary}())] == gf[:,6] |
191 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, UpperBoundary}()) == (11,) | 212 |
192 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, LowerBoundary}()) == (1,) | 213 gf = rand(11) |
193 @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) | |
194 end | 227 end |
195 end | 228 end |
196 | 229 |
197 @testset "combined_coordinate_vector_type" begin | 230 @testset "combined_coordinate_vector_type" begin |
198 @test Grids.combined_coordinate_vector_type(Float64) == Float64 | 231 @test Grids.combined_coordinate_vector_type(Float64) == Float64 |