diff src/Grids/grid.jl @ 1269:20f42cf0800c refactor/grids

Add test for Grid and make them pass. Start implementing eval_on
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 25 Feb 2023 22:22:50 +0100
parents a4ddae8b5d49
children dcbac783e4c1
line wrap: on
line diff
--- a/src/Grids/grid.jl	Fri Feb 24 21:54:39 2023 +0100
+++ b/src/Grids/grid.jl	Sat Feb 25 22:22:50 2023 +0100
@@ -44,11 +44,17 @@
 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?
+"""
+TODO:
 
-function eval_on(::Grid) end # TODO: Should return a LazyArray and index the grid
+* Mention map(f,g) if you want a concrete array
+"""
+eval_on(g::Grid, f) = eval_on(g, f, Base.IteratorSize(g)) # TBD: Borde f vara först som i alla map, sum, och dylikt
+eval_on(g::Grid, f, ::Base.HasShape) = LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g))
+
 
 """
     getcomponent(gfun, I::Vararg{Int})