Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making KernelDensity.pdf interface consistent with Distributions.pdf #122

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
adding Compat
jaksle committed Mar 11, 2024
commit 84eaa9689b7272e5da9ccbab765dae88bd7bd3eb
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ authors = ["Simon Byrne and various contributors"]
version = "0.6.8"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
@@ -17,6 +18,7 @@ FFTW = "1"
Interpolations = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15"
StatsBase = "0.33, 0.34"
julia = "1"
Compat = "3.22, 4"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4 changes: 3 additions & 1 deletion src/interp.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Compat: @compat
import Interpolations: interpolate, scale


mutable struct InterpKDE{K,I} <: AbstractKDE
kde::K
itp::I
@@ -30,7 +32,7 @@ InterpKDE(kde::BivariateKDE) = InterpKDE(kde::BivariateKDE, BSpline(Quadratic(Li
# any dimension
pdf(ik::InterpKDE,x::Real...) = ik.itp(x...)
pdf(ik::InterpKDE, V::AbstractVector) = ik.itp(V...)
pdf(ik::InterpKDE, M::AbstractArray{<:Real, N}) where N = pdf.(ik,eachslice(M, dims=ntuple(i->i+1, N-1)) )
pdf(ik::InterpKDE, M::AbstractArray{<:Real, N}) where N = @compat pdf.(ik,eachslice(M, dims=ntuple(i->i+1, N-1)) )

# 1 dimension
pdf(k::UnivariateKDE,x) = pdf(InterpKDE(k),x)