Mercurial > repos > public > sbplib_julia
comparison src/Grids/tensor_grid.jl @ 1823:054447ac4b0e feature/grids/tensor_grid/spacing
Resolve review comments by filtering ZeroDimGrids
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sun, 20 Oct 2024 20:58:44 +0200 |
parents | 189e69d44056 |
children | 516eaabf1169 |
comparison
equal
deleted
inserted
replaced
1822:189e69d44056 | 1823:054447ac4b0e |
---|---|
45 Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}() | 45 Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}() |
46 Base.length(g::TensorGrid) = prod(length, g.grids) | 46 Base.length(g::TensorGrid) = prod(length, g.grids) |
47 Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...) | 47 Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...) |
48 Base.size(g::TensorGrid, d) = size(g)[d] | 48 Base.size(g::TensorGrid, d) = size(g)[d] |
49 | 49 |
50 # Review: Handle boundary grids as well? | 50 function spacing(g::TensorGrid) |
51 # spacing(boundary_grid(g,id)) fails right now with | 51 relevant_grids = filter(g->!isa(g,ZeroDimGrid),g.grids) |
52 # MethodError: no method matching spacing(::ZeroDimGrid{Float64}) | 52 return spacing.(relevant_grids) |
53 spacing(g::TensorGrid) = spacing.(g.grids) | 53 end |
54 | 54 |
55 function min_spacing(g::TensorGrid) | 55 function min_spacing(g::TensorGrid) |
56 relevant_grids = filter(g->!isa(g,ZeroDimGrid),g.grids) | 56 relevant_grids = filter(g->!isa(g,ZeroDimGrid),g.grids) |
57 d = min_spacing.(relevant_grids) | 57 d = min_spacing.(relevant_grids) |
58 return minimum(d) | 58 return minimum(d) |