Skip to content

Commit

Permalink
put chainrules core in a requires block, rm it from deps (#107)
Browse files Browse the repository at this point in the history
* put chainrules core in a requires block, rm it from deps

* test conditional loading of CRC
  • Loading branch information
vpuri3 authored Jun 19, 2023
1 parent 09d703a commit 3a3f0e4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "1.3.1"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

[extensions]
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
ChainRulesCore = "1"
julia = "^1.0"

[extensions]
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"

[extras]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
Expand All @@ -25,3 +22,6 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["ChainRulesCore", "ChainRulesTestUtils", "Random", "Test", "Unitful"]

[weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
12 changes: 10 additions & 2 deletions src/AbstractFFTs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ export fft, ifft, bfft, fft!, ifft!, bfft!,

include("definitions.jl")

if !isdefined(Base, :get_extension)
include("../ext/AbstractFFTsChainRulesCoreExt.jl")
@static if !isdefined(Base, :get_extension)
import Requires
end

@static if !isdefined(Base, :get_extension)
function __init__()
Requires.@require ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" begin
include("../ext/AbstractFFTsChainRulesCoreExt.jl")
end
end
end

end # module
14 changes: 13 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using AbstractFFTs
using AbstractFFTs: Plan
using ChainRulesTestUtils

using LinearAlgebra
using Random
Expand Down Expand Up @@ -241,6 +240,19 @@ end
end

@testset "ChainRules" begin

if isdefined(Base, :get_extension)
CRCEXT = Base.get_extension(AbstractFFTs, :AbstractFFTsChainRulesCoreExt)
@test isnothing(CRCEXT)
end

using ChainRulesTestUtils

if isdefined(Base, :get_extension)
CRCEXT = Base.get_extension(AbstractFFTs, :AbstractFFTsChainRulesCoreExt)
@test !isnothing(CRCEXT)
end

@testset "shift functions" begin
for x in (randn(3), randn(3, 4), randn(3, 4, 5))
for dims in ((), 1, 2, (1,2), 1:2)
Expand Down

0 comments on commit 3a3f0e4

Please sign in to comment.