Mercurial > repos > public > sbplib_julia
changeset 367:137a62635c49 refactor/remove_dynamic_size_tensormapping
Merge in default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 28 Sep 2020 22:52:49 +0200 |
parents | 33f04f398aac (current diff) 0af6da238d95 (diff) |
children | 0546cb279fc2 |
files | |
diffstat | 2 files changed, 12 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/EquidistantGrid.jl Mon Sep 28 22:46:37 2020 +0200 +++ b/src/Grids/EquidistantGrid.jl Mon Sep 28 22:52:49 2020 +0200 @@ -67,18 +67,18 @@ end """ - subgrid(::EquidistantGrid, dim) + restrict(::EquidistantGrid, dim) Pick out given dimensions from the grid and return a grid for them """ -function subgrid(grid::EquidistantGrid, dim) +function restrict(grid::EquidistantGrid, dim) size = grid.size[dim] limit_lower = grid.limit_lower[dim] limit_upper = grid.limit_upper[dim] return EquidistantGrid(size, limit_lower, limit_upper) end -export subgrid +export restrict function pointsalongdim(grid::EquidistantGrid, dim::Integer) @assert dim<=dimension(grid)
--- a/test/testGrids.jl Mon Sep 28 22:46:37 2020 +0200 +++ b/test/testGrids.jl Mon Sep 28 22:52:49 2020 +0200 @@ -10,17 +10,17 @@ @test EquidistantGrid(4,0.0,1.0) == EquidistantGrid((4,),(0.0,),(1.0,)) g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0)) - @test subgrid(g, 1) == EquidistantGrid(5,0.0,2.0) - @test subgrid(g, 2) == EquidistantGrid(3,0.0,1.0) + @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0) + @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0) g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0)) - @test subgrid(g, 1) == EquidistantGrid(2,0.0,2.0) - @test subgrid(g, 2) == EquidistantGrid(5,0.0,1.0) - @test subgrid(g, 3) == EquidistantGrid(3,0.0,3.0) - @test subgrid(g, 1:2) == EquidistantGrid((2,5),(0.0,0.0),(2.0,1.0)) - @test subgrid(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0)) - @test subgrid(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0)) - @test subgrid(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0)) + @test restrict(g, 1) == EquidistantGrid(2,0.0,2.0) + @test restrict(g, 2) == EquidistantGrid(5,0.0,1.0) + @test restrict(g, 3) == EquidistantGrid(3,0.0,3.0) + @test restrict(g, 1:2) == EquidistantGrid((2,5),(0.0,0.0),(2.0,1.0)) + @test restrict(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0)) + @test restrict(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0)) + @test restrict(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0)) end end