From e2ae06431017e841e2abe23777e49a6464e96020 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Tue, 3 Oct 2023 13:33:30 +0200 Subject: [PATCH 1/2] Use AbstractFFTs instead of FFTW --- Project.toml | 9 +++++---- README.md | 9 +++++++++ src/KernelDensity.jl | 2 +- test/bivariate.jl | 1 + test/interp.jl | 1 + test/univariate.jl | 1 + 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 76c4c188..5d178e86 100644 --- a/Project.toml +++ b/Project.toml @@ -1,25 +1,26 @@ name = "KernelDensity" uuid = "5ab0869b-81aa-558d-bb23-cbf5423bbe9b" authors = ["Simon Byrne and various contributors"] -version = "0.6.7" +version = "0.7.0" [deps] +AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" -FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] +AbstractFFTs = "1" Distributions = "0.23, 0.24, 0.25" DocStringExtensions = "0.8, 0.9" -FFTW = "1" Interpolations = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14" StatsBase = "0.33, 0.34" julia = "1" [extras] +FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["FFTW", "Test"] diff --git a/README.md b/README.md index 02fef541..3f034e42 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,15 @@ Kernel density estimators for Julia. ## Usage +### Prerequisite + +The kernel density estimates are computed with fast Fourier transforms (FFTs) internally using the [AbstractFFTs.jl](https://github.com/JuliaMath/AbstractFFTs.jl) interface. +You have to load a backend such as [FFTW.jl](https://github.com/JuliaMath/FFTW.jl) that implements this interface: + +```julia +using FFTW +``` + ### Univariate The main accessor function is `kde`: diff --git a/src/KernelDensity.jl b/src/KernelDensity.jl index 722e118d..d70e7677 100644 --- a/src/KernelDensity.jl +++ b/src/KernelDensity.jl @@ -6,7 +6,7 @@ using Distributions using Interpolations import Distributions: twoπ, pdf -import FFTW: rfft, irfft +using AbstractFFTs: rfft, irfft export kde, kde_lscv, UnivariateKDE, BivariateKDE, InterpKDE, pdf diff --git a/test/bivariate.jl b/test/bivariate.jl index 5e74f556..fcef9b21 100644 --- a/test/bivariate.jl +++ b/test/bivariate.jl @@ -1,6 +1,7 @@ using Test using Distributions using KernelDensity +using FFTW import KernelDensity: kernel_dist, default_bandwidth, kde_boundary, kde_range, tabulate diff --git a/test/interp.jl b/test/interp.jl index ed93d914..a35e7d56 100644 --- a/test/interp.jl +++ b/test/interp.jl @@ -1,5 +1,6 @@ using Test using KernelDensity +using FFTW X = randn(100) Y = randn(100) diff --git a/test/univariate.jl b/test/univariate.jl index f547713a..eb61bee7 100644 --- a/test/univariate.jl +++ b/test/univariate.jl @@ -1,6 +1,7 @@ using Test using Distributions using KernelDensity +using FFTW import KernelDensity: kernel_dist, default_bandwidth, kde_boundary, kde_range, tabulate From 29b595d6e33f12a9ab16da96f73d9a044b3e72c2 Mon Sep 17 00:00:00 2001 From: David Widmann Date: Tue, 3 Oct 2023 13:57:51 +0200 Subject: [PATCH 2/2] Support AbstractFFTs 0.5 for Julia 1.0 tests --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5d178e86..0493b656 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] -AbstractFFTs = "1" +AbstractFFTs = "0.5, 1" Distributions = "0.23, 0.24, 0.25" DocStringExtensions = "0.8, 0.9" Interpolations = "0.9, 0.10, 0.11, 0.12, 0.13, 0.14"