Mercurial > repos > public > sbplib_julia
changeset 1250:40ca0af6e480 refactor/grids
Add methods to change_length and fix incorrect function declaration
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 22 Feb 2023 12:43:36 +0100 |
parents | 215f36712332 |
children | 6f75f2d2bf5c |
files | src/Grids/equidistant_grid.jl |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Grids/equidistant_grid.jl Wed Feb 22 12:42:38 2023 +0100 +++ b/src/Grids/equidistant_grid.jl Wed Feb 22 12:43:36 2023 +0100 @@ -126,8 +126,10 @@ Change the length of a range to `n`, keeping the same start and stop. """ -function change_length(::AbstractRange, n) end +function change_length end +change_length(r::UnitRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n)) +change_length(r::StepRange, n) = StepRange{Int,Int}(range(r[begin], r[end], n)) +change_length(r::StepRangeLen, n) = range(r[begin], r[end], n) change_length(r::LinRange, n) = LinRange(r[begin], r[end], n) -change_length(r::StepRangeLen, n) = range(r[begin], r[end], n) # TODO: Test the above