Skip to content

Commit e7295ba

Browse files
committed
Drop AbstractFFT interface
1 parent d5f8ca9 commit e7295ba

6 files changed

Lines changed: 24 additions & 17 deletions

File tree

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ version = "0.2.5"
44
authors = ["Danny Sharp <dannys4@mit.edu> and contributors"]
55

66
[deps]
7-
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
87
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
98
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
109
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
@@ -13,7 +12,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1312
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1413

1514
[compat]
16-
AbstractFFTs = "1"
1715
Aqua = "0.8"
1816
DocStringExtensions = "0.9"
1917
ExplicitImports = "1.12"

src/FFTA.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
module FFTA
22

3-
using AbstractFFTs: AbstractFFTs
43
using DocStringExtensions: TYPEDSIGNATURES
54
using LinearAlgebra: LinearAlgebra
65
using MuladdMacro: @muladd
76
using Primes: Primes
87
using Reexport: @reexport
98

10-
@reexport using AbstractFFTs
9+
export fft, bfft, ifft, rfft, brfft, irfft
1110

1211
include("callgraph.jl")
1312
include("algos.jl")
1413
include("plan.jl")
15-
14+
include("main.jl")
1615

1716
end

src/main.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
fft(X::AbstractArray{<:Complex}, region::Union{Int,AbstractVector} = 1:ndims(X)) = plan_fft(X, region) * X
2+
fft(X::AbstractArray, region::Union{Int,AbstractVector} = 1:ndims(X)) = fft(complex(X), region)
3+
4+
bfft(X::AbstractArray{<:Complex}, region::Union{Int,AbstractVector} = 1:ndims(X)) = plan_bfft(X, region) * X
5+
6+
ifft(X::AbstractArray{<:Complex}, region::Union{Int,AbstractVector} = 1:ndims(X)) = bfft(X, region) / mapreduce(Base.Fix1(size, X), *, region; init=1)
7+
8+
rfft(X::AbstractArray{<:Real}, region::Union{Int,AbstractVector} = 1:ndims(X)) = plan_rfft(X, region) * X
9+
10+
brfft(X::AbstractArray{<:Complex}, len::Int, region::Union{Int,AbstractVector} = 1:ndims(X)) = plan_brfft(X, len, region) * X
11+
12+
function irfft(X::AbstractArray{<:Complex}, len::Int, region::Union{Int,AbstractVector} = 1:ndims(X))
13+
Y = brfft(X, len, region)
14+
Y ./= mapreduce(Base.Fix1(size, Y), *, region; init=1)
15+
return Y
16+
end

src/plan.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Plans
2-
3-
abstract type FFTAPlan{T,N} <: AbstractFFTs.Plan{T} end
2+
abstract type FFTAPlan{T,N} end
43

54
struct FFTAInvPlan{T,N} <: FFTAPlan{T,N} end
65

@@ -24,7 +23,7 @@ Base.size(p::FFTAPlan{<:Any,N}) where N = ntuple(Base.Fix1(size, p), Val{N}())
2423

2524
Base.complex(p::FFTAPlan_re{T,N}) where {T,N} = FFTAPlan_cx{T,N}(p.callgraph, p.region, p.dir, p.pinv)
2625

27-
function AbstractFFTs.plan_fft(x::AbstractArray{T,N}, region; kwargs...)::FFTAPlan_cx{T} where {T <: Complex, N}
26+
function plan_fft(x::AbstractArray{T,N}, region; kwargs...)::FFTAPlan_cx{T} where {T <: Complex, N}
2827
FFTN = length(region)
2928
if FFTN == 1
3029
g = CallGraph{T}(size(x,region[]))
@@ -41,7 +40,7 @@ function AbstractFFTs.plan_fft(x::AbstractArray{T,N}, region; kwargs...)::FFTAPl
4140
end
4241
end
4342

44-
function AbstractFFTs.plan_bfft(x::AbstractArray{T,N}, region; kwargs...)::FFTAPlan_cx{T} where {T <: Complex,N}
43+
function plan_bfft(x::AbstractArray{T,N}, region::Union{Int,AbstractVector})::FFTAPlan_cx{T} where {T <: Complex,N}
4544
FFTN = length(region)
4645
if FFTN == 1
4746
g = CallGraph{T}(size(x,region[]))
@@ -58,7 +57,7 @@ function AbstractFFTs.plan_bfft(x::AbstractArray{T,N}, region; kwargs...)::FFTAP
5857
end
5958
end
6059

61-
function AbstractFFTs.plan_rfft(x::AbstractArray{T,N}, region; kwargs...)::FFTAPlan_re{Complex{T}} where {T <: Real,N}
60+
function plan_rfft(x::AbstractArray{T,N}, region::Union{Int,AbstractVector})::FFTAPlan_re{Complex{T}} where {T <: Real,N}
6261
FFTN = length(region)
6362
if FFTN == 1
6463
g = CallGraph{Complex{T}}(size(x,region[]))
@@ -78,7 +77,7 @@ function AbstractFFTs.plan_rfft(x::AbstractArray{T,N}, region; kwargs...)::FFTAP
7877
end
7978
end
8079

81-
function AbstractFFTs.plan_brfft(x::AbstractArray{T,N}, len, region; kwargs...)::FFTAPlan_re{T} where {T,N}
80+
function plan_brfft(x::AbstractArray{T,N}, len::Int, region::Union{Int,AbstractVector})::FFTAPlan_re{T} where {T,N}
8281
FFTN = length(region)
8382
if FFTN == 1
8483
g = CallGraph{T}(len)

test/qa/aqua.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ import Aqua
44
@testset "Aqua" begin
55
Aqua.test_all(
66
FFTA;
7-
# This type piracy is caused by the problematic design of AbstractFFTs.jl
8-
# Ref https://github.com/JuliaMath/AbstractFFTs.jl/issues/32
9-
piracies = (; treat_as_own = [plan_bfft, plan_brfft, plan_fft, plan_rfft]),
107
)
118
end

test/qa/explicit_imports.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import ExplicitImports
1818
@test ExplicitImports.check_all_qualified_accesses_via_owners(FFTA) === nothing
1919

2020
# No non-public accesses in FFTA (ie. no `... MyPkg._non_public_internal_func(...)`)
21-
# AbstractFFTs requires subtyping of `Plan` but it is not public
22-
# This is an upstream bug in AbstractFFTs.jl
23-
@test ExplicitImports.check_all_qualified_accesses_are_public(FFTA; ignore = (:Plan, :require_one_based_indexing, :Fix1)) === nothing
21+
@test ExplicitImports.check_all_qualified_accesses_are_public(FFTA; ignore = (:require_one_based_indexing, :Fix1)) === nothing
2422

2523
# No self-qualified accesses in FFTA (ie. no `... FFTA.func(...)`)
2624
@test ExplicitImports.check_no_self_qualified_accesses(FFTA) === nothing

0 commit comments

Comments
 (0)