diff --git a/src/KDE01.jl b/src/KDE01.jl index f43c59f..a7af13d 100644 --- a/src/KDE01.jl +++ b/src/KDE01.jl @@ -140,7 +140,7 @@ end Extract the marginal distribution from the given higher dimensional kernel density estimate object. """ -function marginal(bd::BallTreeDensity, ind::Array{Int,1}) +function marginal(bd::BallTreeDensity, ind::AbstractVector{<:Integer}) pts = getPoints(bd) if size(bd.bandwidth,2) > 2*bd.bt.num_points sig = getBW(bd) @@ -152,12 +152,12 @@ function marginal(bd::BallTreeDensity, ind::Array{Int,1}) p = kde!(pts[ind,:],sig[ind], wts) end -function randKernel(N::Int, M::Int, ::Type{KernelDensityEstimate.GaussianKer}) #t::Int) +function randKernel(N::Int, M::Int, ::Type{<:KernelDensityEstimate.GaussianKer}) #t::Int) return randn(N,M) end """ - $(SIGNATURES) + $(SIGNATURES) Randomly sample points from the KernelDensityEstimate object. """ diff --git a/src/StringSerialization.jl b/src/StringSerialization.jl index 5c208dd..1b86dcd 100644 --- a/src/StringSerialization.jl +++ b/src/StringSerialization.jl @@ -1,16 +1,16 @@ -function string(d::KernelDensityEstimate.BallTreeDensity) +function Base.string(d::KernelDensityEstimate.BallTreeDensity) # TODO only supports single bandwidth per dimension at this point pts = getPoints(d) return "KDE:$(size(pts,2)):$(getBW(d)[:,1]):$(pts)" end -function parsestringvector(str::AS; dlim=',') where {AS <: AbstractString} +function parsestringvector(str::AbstractString; dlim=',') sstr = split(split(strip(str),'[')[end],']')[1] ssstr = strip.(split(sstr,dlim)) parse.(Float64, ssstr) end -function convert(::Type{BallTreeDensity}, str::AS) where {AS <: AbstractString} +function convert(::Type{<:BallTreeDensity}, str::AbstractString) @assert occursin(r"KDE:", str) # ismatch sstr = strip.(split(str, ':')) N = parse(Int, sstr[2])