Skip to content

Commit be75369

Browse files
committed
Adapt TestPlans module to backend approach.
The definition of plan_fft with where T causes ambig. with the AbstractArray{<:Real} abstract methods. Restricting the type to the appropriate datatypes fixes it, but requires a change in an upstream package. I think most packages which call into jlls restrict themselves already
1 parent 9fef024 commit be75369

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

test/TestPlans.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ using LinearAlgebra
44
using AbstractFFTs
55
using AbstractFFTs: Plan
66

7+
struct TestBackend <: AbstractFFTBackend end
8+
backend() = TestBackend()
9+
activate!() = AbstractFFTs.set_active_backend!(TestPlans)
10+
711
mutable struct TestPlan{T,N,G} <: Plan{T}
812
region::G
913
sz::NTuple{N,Int}
@@ -30,10 +34,10 @@ Base.ndims(::InverseTestPlan{T,N}) where {T,N} = N
3034
AbstractFFTs.AdjointStyle(::TestPlan) = AbstractFFTs.FFTAdjointStyle()
3135
AbstractFFTs.AdjointStyle(::InverseTestPlan) = AbstractFFTs.FFTAdjointStyle()
3236

33-
function AbstractFFTs.plan_fft(x::AbstractArray{T}, region; kwargs...) where {T}
37+
function AbstractFFTs.plan_fft(::TestBackend, x::AbstractArray{T}, region; kwargs...) where {T <: Complex}
3438
return TestPlan{T}(region, size(x))
3539
end
36-
function AbstractFFTs.plan_bfft(x::AbstractArray{T}, region; kwargs...) where {T}
40+
function AbstractFFTs.plan_bfft(::TestBackend, x::AbstractArray{T}, region; kwargs...) where {T <: Complex}
3741
return InverseTestPlan{T}(region, size(x))
3842
end
3943

@@ -119,10 +123,10 @@ end
119123
AbstractFFTs.AdjointStyle(::TestRPlan) = AbstractFFTs.RFFTAdjointStyle()
120124
AbstractFFTs.AdjointStyle(p::InverseTestRPlan) = AbstractFFTs.IRFFTAdjointStyle(p.d)
121125

122-
function AbstractFFTs.plan_rfft(x::AbstractArray{T}, region; kwargs...) where {T<:Real}
126+
function AbstractFFTs.plan_rfft(::TestBackend, x::AbstractArray{T}, region; kwargs...) where {T<:Real}
123127
return TestRPlan{T}(region, size(x))
124128
end
125-
function AbstractFFTs.plan_brfft(x::AbstractArray{Complex{T}}, d, region; kwargs...) where {T}
129+
function AbstractFFTs.plan_brfft(::TestBackend, x::AbstractArray{Complex{T}}, d, region; kwargs...) where {T}
126130
return InverseTestRPlan{T}(d, region, size(x))
127131
end
128132
function AbstractFFTs.plan_inv(p::TestRPlan{T,N}) where {T,N}
@@ -265,10 +269,10 @@ Base.ndims(p::InplaceTestPlan) = ndims(p.plan)
265269
AbstractFFTs.fftdims(p::InplaceTestPlan) = fftdims(p.plan)
266270
AbstractFFTs.AdjointStyle(p::InplaceTestPlan) = AbstractFFTs.AdjointStyle(p.plan)
267271

268-
function AbstractFFTs.plan_fft!(x::AbstractArray, region; kwargs...)
272+
function AbstractFFTs.plan_fft!(::TestBackend, x::AbstractArray, region; kwargs...)
269273
return InplaceTestPlan(plan_fft(x, region; kwargs...))
270274
end
271-
function AbstractFFTs.plan_bfft!(x::AbstractArray, region; kwargs...)
275+
function AbstractFFTs.plan_bfft!(::TestBackend, x::AbstractArray, region; kwargs...)
272276
return InplaceTestPlan(plan_bfft(x, region; kwargs...))
273277
end
274278

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Random.seed!(1234)
1616

1717
# Load example plan implementation.
1818
include("TestPlans.jl")
19+
TestPlans.activate!()
1920

2021
# Run interface tests for TestPlans
2122
AbstractFFTs.TestUtils.test_complex_ffts(Array)

0 commit comments

Comments
 (0)