Skip to content

Commit c1d43db

Browse files
committed
use improved high numerical precision range from Base
KernelDensity.jl rolled its own range generator which suffers from similar flaws as Base's linspace prior to being fixed in JuliaLang/julia#18777. This closes JuliaStats#39.
1 parent bf4191d commit c1d43db

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/univariate.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ function kde_range(boundary::Tuple{Real,Real}, npoints::Int)
6666
lo, hi = boundary
6767
lo < hi || error("boundary (a,b) must have a < b")
6868

69-
step = (hi - lo) / (npoints-1)
70-
lo:step:hi
69+
Compat.range(lo, stop=hi, length=npoints)
7170
end
7271

7372
struct UniformWeights{N} end

test/univariate.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ end
1313

1414
r = kde_range((-2.0,2.0), 128)
1515
@test step(r) > 0
16+
r2 = kde_range((0.12698109160784082, 0.9785547869337731), 256)
17+
@test length(r2) == 256
1618

1719
for X in ([0.0], [0.0,0.0], [0.0,0.5], [-0.5:0.1:0.5;])
1820
w = default_bandwidth(X)

0 commit comments

Comments
 (0)