changeset 324:047dee8efaef

Grids.EquidistantGrid: Add constructor for 1d grid
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 24 Sep 2020 21:28:28 +0200
parents b2ddc5e4d41a
children 41c3c25e4e3b
files Grids/src/EquidistantGrid.jl Grids/test/runtests.jl
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Grids/src/EquidistantGrid.jl	Thu Sep 24 21:04:25 2020 +0200
+++ b/Grids/src/EquidistantGrid.jl	Thu Sep 24 21:28:28 2020 +0200
@@ -21,6 +21,10 @@
     end
 end
 
+function EquidistantGrid(size::Int, limit_lower::T, limit_upper::T) where T
+	return EquidistantGrid((size,),(limit_lower,),(limit_upper,))
+end
+
 function Base.eachindex(grid::EquidistantGrid)
     CartesianIndices(grid.size)
 end
--- a/Grids/test/runtests.jl	Thu Sep 24 21:04:25 2020 +0200
+++ b/Grids/test/runtests.jl	Thu Sep 24 21:28:28 2020 +0200
@@ -1,4 +1,8 @@
 using Grids
 using Test
 
-@test_broken false
+@testset "EquidistantGrid" begin
+    @test EquidistantGrid(4,0,1) isa EquidistantGrid
+    @test dimension(EquidistantGrid(4,0,1)) == 1
+    @test EquidistantGrid(4,0,1) == EquidistantGrid((4,),(0,),(1,))
+end