Skip to content

Commit 24e5e8a

Browse files
author
Kristoffer Carlsson
authored
make ChainRulesCore dependency into an extension (#421)
1 parent 5d33031 commit 24e5e8a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Project.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
99
OpenLibm_jll = "05823500-19ac-5b8b-9628-191a04bc5112"
1010
OpenSpecFun_jll = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
1111

12+
[weakdeps]
13+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
14+
15+
[extensions]
16+
ChainRulesCoreExt = "ChainRulesCore"
17+
1218
[compat]
1319
ChainRulesCore = "0.9.44, 0.10, 1"
1420
ChainRulesTestUtils = "0.6.8, 0.7, 1"
@@ -19,9 +25,10 @@ OpenSpecFun_jll = "0.5"
1925
julia = "1.3"
2026

2127
[extras]
28+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
2229
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
2330
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2431
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2532

2633
[targets]
27-
test = ["ChainRulesTestUtils", "Random", "Test"]
34+
test = ["ChainRulesCore", "ChainRulesTestUtils", "Random", "Test"]

src/chainrules.jl renamed to ext/ChainRulesCoreExt.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
module ChainRulesCoreExt
2+
3+
using SpecialFunctions, ChainRulesCore
4+
5+
import SpecialFunctions: sqrtπ, invπ
6+
17
const BESSEL_ORDER_INFO = """
28
derivatives of Bessel functions with respect to the order are not implemented currently:
39
https://github.com/JuliaMath/SpecialFunctions.jl/issues/160
@@ -293,3 +299,5 @@ function ChainRulesCore.rrule(::typeof(besselyx), ν::Number, x::Number)
293299
end
294300
return Ω, besselyx_pullback
295301
end
302+
303+
end # module

src/SpecialFunctions.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ using IrrationalConstants:
1313
logπ,
1414
log2π
1515

16-
import ChainRulesCore
1716
import LogExpFunctions
1817

1918
using OpenLibm_jll
@@ -91,7 +90,9 @@ include("gamma.jl")
9190
include("gamma_inc.jl")
9291
include("betanc.jl")
9392
include("beta_inc.jl")
94-
include("chainrules.jl")
93+
if !isdefined(Base, :get_extension)
94+
include("../ext/ChainRulesCoreExt.jl")
95+
end
9596
include("deprecated.jl")
9697

9798
for f in (:digamma, :erf, :erfc, :erfcinv, :erfcx, :erfi, :erfinv, :logerfc, :logerfcx,

0 commit comments

Comments
 (0)