Mercurial > repos > public > sbplib_julia
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1268:dbddd0f61bde | 1269:20f42cf0800c |
|---|---|
| 42 dims(grid::Grid) | 42 dims(grid::Grid) |
| 43 | 43 |
| 44 Enumerate the dimensions of the grid. | 44 Enumerate the dimensions of the grid. |
| 45 """ | 45 """ |
| 46 dims(grid::Grid) = 1:ndims(grid) | 46 dims(grid::Grid) = 1:ndims(grid) |
| 47 | 47 # TBD: Is this function needed? Where is it used? |
| 48 | 48 |
| 49 # TBD: New file grid_functions.jl? | 49 # TBD: New file grid_functions.jl? |
| 50 """ | |
| 51 TODO: | |
| 50 | 52 |
| 51 function eval_on(::Grid) end # TODO: Should return a LazyArray and index the grid | 53 * Mention map(f,g) if you want a concrete array |
| 54 """ | |
| 55 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 | |
| 56 eval_on(g::Grid, f, ::Base.HasShape) = LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) | |
| 57 | |
| 52 | 58 |
| 53 """ | 59 """ |
| 54 getcomponent(gfun, I::Vararg{Int}) | 60 getcomponent(gfun, I::Vararg{Int}) |
| 55 | 61 |
| 56 Return one of the components of gfun as a grid function. | 62 Return one of the components of gfun as a grid function. |
