Skip to content

Commit

Permalink
adds support for ranges in setindex! and getindex
Browse files Browse the repository at this point in the history
  • Loading branch information
svretina committed Jan 10, 2025
1 parent 0840a06 commit 572c2d3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ end
function Base.getindex(f::GridFunction, i)
if f.periodic
N = f.grid.ncells + 1
if i > N
return f.values[i-N]
elseif i < 1
return f.values[i+N]
if i .> N
return f.values[i.-N]
elseif i .< 1
return f.values[i.+N]
else
return f.values[i]
end
Expand All @@ -57,7 +57,7 @@ end


function Base.setindex!(f::GridFunction, x, i)
f.values[i] = x
f.values[i] .= x
return nothing
end

Expand Down

0 comments on commit 572c2d3

Please sign in to comment.