Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only define rules for SpecialFunctions if needed #320

Merged
merged 7 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRules"
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
version = "0.7.36"
version = "0.7.37"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
6 changes: 5 additions & 1 deletion src/ChainRules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ function __init__()
include("rulesets/packages/NaNMath.jl")
end

# Note: drop SpecialFunctions dependency in next breaking release
# https://github.com/JuliaDiff/ChainRules.jl/issues/319
@require SpecialFunctions="276daf66-3868-5448-9aa4-cd146d93841b" begin
include("rulesets/packages/SpecialFunctions.jl")
if !isdefined(SpecialFunctions, :ChainRulesCore)
include("rulesets/packages/SpecialFunctions.jl")
end
end
end

Expand Down
2 changes: 0 additions & 2 deletions test/rulesets/packages/SpecialFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using SpecialFunctions

@testset "SpecialFunctions" for x in (1.0, -1.0, 0.0, 0.5, 10.0, -17.1, 1.5 + 0.7im)
test_scalar(SpecialFunctions.erf, x)
test_scalar(SpecialFunctions.erfc, x)
Expand Down
7 changes: 6 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using ChainRulesTestUtils: rand_tangent, _fdm
using Compat: only
using FiniteDifferences
using FiniteDifferences: rand_tangent
using SpecialFunctions
using LinearAlgebra
using LinearAlgebra.BLAS
using LinearAlgebra: dot
Expand Down Expand Up @@ -56,7 +57,11 @@ println("Testing ChainRules.jl")

@testset "packages" begin
include_test("rulesets/packages/NaNMath.jl")
include_test("rulesets/packages/SpecialFunctions.jl")
# Note: drop SpecialFunctions dependency in next breaking release
# https://github.com/JuliaDiff/ChainRules.jl/issues/319
if !isdefined(SpecialFunctions, :ChainRulesCore)
include_test("rulesets/packages/SpecialFunctions.jl")
end
end
println()
end
Expand Down