diff src/Grids/equidistant_grid.jl @ 1529:43aaf710463e refactor/equidistant_grid/signature

Change to signature of equidistant_grid to same style as many array methods. See for example Array{T}(undef, dims...), zeros(T, dims...), fill(a, dims...) and more.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 11 Apr 2024 22:31:04 +0200
parents d7bc11053951
children 9113f437431d c3425b4302b8 efe1fc4cb6b0
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl	Wed Apr 10 09:01:54 2024 +0200
+++ b/src/Grids/equidistant_grid.jl	Thu Apr 11 22:31:04 2024 +0200
@@ -88,7 +88,7 @@
 
 
 """
-    equidistant_grid(size::Dims, limit_lower, limit_upper)
+    equidistant_grid(limit_lower, limit_upper, dims...)
 
 Construct an equidistant grid with corners at the coordinates `limit_lower` and
 `limit_upper`.
@@ -99,24 +99,24 @@
 of the grid are not allowed to be negative.
 
 The number of equispaced points in each coordinate direction are given
-by the tuple `size`.
+by the tuple `dims`.
 
-Note: If `limit_lower` and `limit_upper` are integers and `size` would allow a
+Note: If `limit_lower` and `limit_upper` are integers and `dims` would allow a
 completely integer grid, `equidistant_grid` will still return a floating point
 grid. This simplifies the implementation and avoids certain surprise
 behaviors.
 """
-function equidistant_grid(size::Dims, limit_lower, limit_upper)
-    gs = map(equidistant_grid, size, limit_lower, limit_upper)
+function equidistant_grid(limit_lower, limit_upper, dims::Vararg{Int})
+    gs = map(equidistant_grid, limit_lower, limit_upper, dims)
     return TensorGrid(gs...)
 end
 
 """
-    equidistant_grid(size::Int, limit_lower::T, limit_upper::T)
+    equidistant_grid(limit_lower::T, limit_upper::T, size::Int)
 
 Constructs a 1D equidistant grid.
 """
-function equidistant_grid(size::Int, limit_lower::T, limit_upper::T) where T
+function equidistant_grid(limit_lower::T, limit_upper::T, size::Int) where T
     if any(size .<= 0)
         throw(DomainError("size must be postive"))
     end