Mercurial > repos > public > sbplib_julia
diff src/Grids/tensor_grid.jl @ 1399:adbdbf1c3480 bugfix/grids/complete_interface_impl
Replace `firstindex` and `lastindex` with implementation of `axes`
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Aug 2023 09:00:34 +0200 |
parents | 60857d8338cb |
children | 18e21601da2d |
line wrap: on
line diff
--- a/src/Grids/tensor_grid.jl Tue Aug 22 08:59:47 2023 +0200 +++ b/src/Grids/tensor_grid.jl Tue Aug 22 09:00:34 2023 +0200 @@ -31,17 +31,11 @@ return CartesianIndices(szs) end -function Base.firstindex(g::TensorGrid, d) +function Base.axes(g::TensorGrid, d) i, ld = grid_and_local_dim_index(ndims.(g.grids), d) - return firstindex(g.grids[i], ld) + return axes(g.grids[i], ld) end -function Base.lastindex(g::TensorGrid, d) - i, ld = grid_and_local_dim_index(ndims.(g.grids), d) - return lastindex(g.grids[i], ld) -end -# TBD: Should the two above functions be supported by implementing `axes` instead? - # Iteration interface Base.iterate(g::TensorGrid) = iterate(Iterators.product(g.grids...)) |> _iterate_combine_coords Base.iterate(g::TensorGrid, state) = iterate(Iterators.product(g.grids...), state) |> _iterate_combine_coords