changeset 1279:1157f889bf50 refactor/grids

Clear out some TBDs
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 26 Feb 2023 21:20:52 +0100
parents 4a0570f325ce
children 17d435c08773
files grid_refactor.md src/Grids/equidistant_grid.jl src/Grids/grid.jl test/Grids/equidistant_grid_test.jl test/Grids/grid_test.jl
diffstat 5 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/grid_refactor.md	Sun Feb 26 21:04:41 2023 +0100
+++ b/grid_refactor.md	Sun Feb 26 21:20:52 2023 +0100
@@ -11,6 +11,7 @@
 * Grids embedded in higher dimensions are now supported through tensor products with `ZeroDimGrid`s.
 * Vector valued grid functions are now supported and the default element type is `SVector`.
 * Grids are now expected to support Julia's indexing and iteration interface.
+* `eval_on` can be called with both `f(x,y,...)` and `f(x̄)`.
 
 
 ## TODO
--- a/src/Grids/equidistant_grid.jl	Sun Feb 26 21:04:41 2023 +0100
+++ b/src/Grids/equidistant_grid.jl	Sun Feb 26 21:20:52 2023 +0100
@@ -134,4 +134,3 @@
 change_length(r::StepRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n))
 change_length(r::StepRangeLen, n) = range(r[begin], r[end], n)
 change_length(r::LinRange, n) = LinRange(r[begin], r[end], n)
-# TODO: Test the above
--- a/src/Grids/grid.jl	Sun Feb 26 21:04:41 2023 +0100
+++ b/src/Grids/grid.jl	Sun Feb 26 21:20:52 2023 +0100
@@ -3,14 +3,12 @@
 
 The top level type for grids.
 
+TODO:
 Should implement
-# TBD:
+ * interfaces for iteration and indexing
 """
-#TBD: Should it be an AbstractArray? See notes in grid_refactor.md
-# TODO: Document that grids should implement the interfaces for iteration and indexing.
 abstract type Grid{T,D} end
 
-
 Base.ndims(::Grid{T,D}) where {T,D} = D
 Base.eltype(::Type{<:Grid{T}}) where T = T
 target_manifold_dim(::Grid{T}) where T = _ncomponents(T) # TBD: Name of this function?!
@@ -45,9 +43,7 @@
 Enumerate the dimensions of the grid.
 """
 dims(grid::Grid) = 1:ndims(grid)
-# TBD: Is this function needed? Where is it used?
-
-# TBD: New file grid_functions.jl?
+# TBD: Is this function needed? Where is it used
 """
 TODO:
 
@@ -63,7 +59,7 @@
 end
 
 
-# TODO: Explain how these are intended to be used
+# TODO: Explain how and where these are intended to be used
 _ncomponents(::Type{<:Number}) = 1
 _ncomponents(T::Type{<:SVector}) = length(T)
 
--- a/test/Grids/equidistant_grid_test.jl	Sun Feb 26 21:04:41 2023 +0100
+++ b/test/Grids/equidistant_grid_test.jl	Sun Feb 26 21:20:52 2023 +0100
@@ -55,7 +55,7 @@
 
     @testset "boundary_grid" begin
         g = EquidistantGrid(0:0.1:1)
-        @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0) # TBD: Is fill necessary here? Why?
+        @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0)
         @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0)
     end
 
--- a/test/Grids/grid_test.jl	Sun Feb 26 21:04:41 2023 +0100
+++ b/test/Grids/grid_test.jl	Sun Feb 26 21:20:52 2023 +0100
@@ -21,6 +21,9 @@
     @test eval_on(ZeroDimGrid(@SVector[1.,2.]), x̄->x̄[1]+x̄[2]) == fill(3.)
     @test eval_on(ZeroDimGrid(@SVector[3.,2.]), x̄->x̄[1]+x̄[2]) == fill(5.)
 
+    @test eval_on(ZeroDimGrid(1.), x̄->2x̄) isa LazyArray
+    @test eval_on(ZeroDimGrid(1.), x̄->2x̄) == fill(2.)
+
     @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) isa LazyArray
     @test eval_on(EquidistantGrid(range(0,1,length=4)), x->2x) == 2 .* range(0,1,length=4)