Skip to content

Commit

Permalink
use improved high numerical precision range from Base (#52)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlnagy authored and ararslan committed Jun 10, 2018
1 parent bf4191d commit a0a0859
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function kde_range(boundary::Tuple{Real,Real}, npoints::Int)
lo, hi = boundary
lo < hi || error("boundary (a,b) must have a < b")

step = (hi - lo) / (npoints-1)
lo:step:hi
Compat.range(lo, stop=hi, length=npoints)
end

struct UniformWeights{N} end
Expand Down
2 changes: 2 additions & 0 deletions test/univariate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ end

r = kde_range((-2.0,2.0), 128)
@test step(r) > 0
r2 = kde_range((0.12698109160784082, 0.9785547869337731), 256)
@test length(r2) == 256

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

0 comments on commit a0a0859

Please sign in to comment.