Skip to content

Commit

Permalink
improve eltype of symrange
Browse files Browse the repository at this point in the history
  • Loading branch information
jw3126 committed Nov 24, 2021
1 parent 6dcca19 commit bf7a28e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RangeHelpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ function _symrange(center, start, step, stop, length)
end

function _symrange(center, start::Nothing, step, stop::Nothing, length)
c = float(something(center, zero(step)))
c = float(center*one(step))
if isodd(length)
hl = Int((length - 1)/2)
anchorrange(c, pre=hl, post=hl, step=step)
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ end

r = @inferred symrange(stop=strictabove(-2), step=-1)
@test r === 1.5:-1.0:-1.5

r = @inferred symrange(step=2.5f0, length=106)
@test eltype(r) === Float32
end

@testset "prolong" begin
Expand Down

0 comments on commit bf7a28e

Please sign in to comment.