Skip to content

Commit

Permalink
use improved high numerical precision linspace from Base
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 committed Jun 3, 2018
1 parent bf4191d commit 8a6b97c
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
linspace(lo, hi, 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
r = kde_range((0.12698109160784082, 0.9785547869337731), 256)
@test length(r) == 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 8a6b97c

Please sign in to comment.