Skip to content

Commit 43880cf

Browse files
authored
Replace Base.floatrange with simplified implementation (#792)
* Replace Base.floatrange with simplified implementation Base.floatrange has bugs and is not public API anymore See JuliaLang/julia#45336 Use a simplified implementation instead * Inline floatrange
1 parent d9cb8f8 commit 43880cf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/hist.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ function histrange(lo::F, hi::F, n::Integer, closed::Symbol=:left) where F
9696
len += one(F)
9797
end
9898
end
99-
Base.floatrange(start,step,Int(len),divisor)
99+
StepRangeLen(Base.TwicePrecision{Float64}((start, divisor)),
100+
Base.TwicePrecision{Float64}((step, divisor)),
101+
Int(len))
100102
end
101103

102104
histrange(vs::NTuple{N,AbstractVector},nbins::NTuple{N,Integer},closed::Symbol) where {N} =

test/hist.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ end
107107
@test l <= typemin(Int)
108108
@test h >= typemax(Int)
109109

110+
# Issue 616/667
111+
@test StatsBase.histrange([1.0 for i in 1:100], 10, :left) == 1.0:1.0:2.0
112+
@test StatsBase.histrange([1.05 for i in 1:100], 10, :left) == 1.05:1.0:2.05
113+
110114
@test_throws ArgumentError StatsBase.histrange([1, 10], 0, :left)
111115
@test_throws ArgumentError StatsBase.histrange([1, 10], -1, :left)
112116
@test_throws ArgumentError StatsBase.histrange([1.0, 10.0], 0, :left)

0 commit comments

Comments
 (0)