Skip to content

Commit a0a0859

Browse files
tlnagyararslan
authored andcommittedJun 10, 2018
use improved high numerical precision range from Base (#52)
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 #39.
1 parent bf4191d commit a0a0859

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎src/univariate.jl

+1-2
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

+2
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)
Please sign in to comment.