Skip to content

Commit

Permalink
RingGrinds more general indexing with Colon (less escapes)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilian-gelbrecht committed Dec 13, 2024
1 parent 4f07e4d commit 6b0d4fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RingGrids/general.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Base.@propagate_inbounds Base.getindex(G::AbstractGridArray, ijk...) = getindex(
@inline function Base.getindex(
G::GridArray,
col::Colon,
k::Integer...,
k...,
) where {GridArray<:AbstractGridArray}
GridArray_ = nonparametric_type(GridArray) # obtain parameters from G.data
return GridArray_(getindex(G.data, col, k...), G.nlat_half, G.rings)
Expand Down
3 changes: 3 additions & 0 deletions test/grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ end
@test grid[1:2, 1:2, 1:2] == grid.data[1:2, 1:2, 1:2]
@test grid[1, 1, :] == grid.data[1, 1, :]

@test SpeedyWeather.RingGrids.nonparametric_type(typeof(grid[:,1:2,1:2])) <: RingGrids.nonparametric_type(G)
@test grid[:, 1:2, 1:2].data == grid.data[:, 1:2, 1:2]

idx = CartesianIndex((1, 2, 3))
@test grid[idx] == grid.data[idx]

Expand Down

0 comments on commit 6b0d4fa

Please sign in to comment.