Skip to content

Commit 8d30c5e

Browse files
Merge pull request #308 from JuliaDiff/os/remove-tricks
Remove Tricks
2 parents 4e36edd + 4601a51 commit 8d30c5e

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2424
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2525
StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718"
2626
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
27-
Tricks = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
2827
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
2928
VertexSafeGraphs = "19fa3120-7c27-5ec5-8db8-b0b0aa330d6f"
3029

@@ -64,7 +63,6 @@ SparseArrays = "<0.0.1, 1"
6463
StaticArrayInterface = "1.3"
6564
StaticArrays = "1"
6665
Symbolics = "5.5, 6"
67-
Tricks = "0.1.6"
6866
UnPack = "1"
6967
VertexSafeGraphs = "0.2"
7068
Zygote = "0.6"

ext/SparseDiffToolsZygoteExt.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import SparseDiffTools: SparseDiffTools, DeivVecTag, AutoDiffVJP, __test_backend
55
import ForwardDiff: ForwardDiff, Dual, partials
66
import SciMLOperators: update_coefficients, update_coefficients!
77
import Setfield: @set!
8-
import Tricks: static_hasmethod
98

109
import SparseDiffTools: numback_hesvec!,
1110
numback_hesvec, autoback_hesvec!, autoback_hesvec, auto_vecjac!,
@@ -101,7 +100,7 @@ end
101100

102101
# VJP methods
103102
function auto_vecjac!(du, f::F, x, v) where {F}
104-
!static_hasmethod(f, typeof((x,))) &&
103+
!hasmethod(f, typeof((x,))) &&
105104
error("For inplace function use autodiff = AutoFiniteDiff()")
106105
du .= reshape(SparseDiffTools.auto_vecjac(f, x, v), size(du))
107106
end
@@ -113,7 +112,7 @@ end
113112

114113
# overload operator interface
115114
function SparseDiffTools._vecjac(f::F, _, u, autodiff::AutoZygote) where {F}
116-
!static_hasmethod(f, typeof((u,))) &&
115+
!hasmethod(f, typeof((u,))) &&
117116
error("For inplace function use autodiff = AutoFiniteDiff()")
118117
pullback = Zygote.pullback(f, u)
119118
return AutoDiffVJP(f, u, (), autodiff, pullback)

src/SparseDiffTools.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ using SciMLOperators, LinearAlgebra, Random
2222
import DataStructures: DisjointSets, find_root!, union!
2323
import SciMLOperators: update_coefficients, update_coefficients!
2424
import Setfield: @set!
25-
import Tricks: Tricks, static_hasmethod
2625

2726
import PackageExtensionCompat: @require_extensions
2827
function __init__()

src/differentiation/common.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function JacFunctionWrapper(f::F, fu_, u, p, t;
4949
if deporder
5050
# Check this first else we were breaking things
5151
# In the next breaking release, we will fix the ordering of the checks
52-
iip = static_hasmethod(f, typeof((fu, u)))
53-
oop = static_hasmethod(f, typeof((u,)))
52+
iip = hasmethod(f, typeof((fu, u)))
53+
oop = hasmethod(f, typeof((u,)))
5454
if iip || oop
5555
if p !== nothing || t !== nothing
5656
Base.depwarn(
@@ -74,17 +74,17 @@ function JacFunctionWrapper(f::F, fu_, u, p, t;
7474
end
7575

7676
if t !== nothing
77-
iip = static_hasmethod(f, typeof((fu, u, p, t)))
78-
oop = static_hasmethod(f, typeof((u, p, t)))
77+
iip = hasmethod(f, typeof((fu, u, p, t)))
78+
oop = hasmethod(f, typeof((u, p, t)))
7979
if !iip && !oop
8080
throw(ArgumentError("""`p` and `t` provided but `f(u, p, t)` or `f(fu, u, p, t)`
8181
not defined for `f`!"""))
8282
end
8383
return JacFunctionWrapper{iip, oop, 1, F, typeof(fu), typeof(p), typeof(t)}(f,
8484
fu, p, t)
8585
elseif p !== nothing
86-
iip = static_hasmethod(f, typeof((fu, u, p)))
87-
oop = static_hasmethod(f, typeof((u, p)))
86+
iip = hasmethod(f, typeof((fu, u, p)))
87+
oop = hasmethod(f, typeof((u, p)))
8888
if !iip && !oop
8989
throw(ArgumentError("""`p` is provided but `f(u, p)` or `f(fu, u, p)`
9090
not defined for `f`!"""))
@@ -94,8 +94,8 @@ function JacFunctionWrapper(f::F, fu_, u, p, t;
9494
end
9595

9696
if !deporder
97-
iip = static_hasmethod(f, typeof((fu, u)))
98-
oop = static_hasmethod(f, typeof((u,)))
97+
iip = hasmethod(f, typeof((fu, u)))
98+
oop = hasmethod(f, typeof((u,)))
9999
if !iip && !oop
100100
throw(ArgumentError("""`p` is provided but `f(u)` or `f(fu, u)` not defined for
101101
`f`!"""))

src/differentiation/jaches_products.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function (L::FwdModeAutoDiffVecProd)(dv, v, p, t)
212212
end
213213

214214
function Base.resize!(L::FwdModeAutoDiffVecProd, n::Integer)
215-
static_hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n)
215+
hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n)
216216
resize!(L.u, n)
217217

218218
for v in L.cache
@@ -304,7 +304,7 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing;
304304

305305
(cache1, cache2, cache3), numauto_hesvec, numauto_hesvec!
306306
elseif autodiff isa AutoZygote
307-
@assert static_hasmethod(autoback_hesvec, typeof((f, u, u))) "To use AutoZygote() AD, first load Zygote with `using Zygote`, or `import Zygote`"
307+
@assert hasmethod(autoback_hesvec, typeof((f, u, u))) "To use AutoZygote() AD, first load Zygote with `using Zygote`, or `import Zygote`"
308308

309309
cache1 = Dual{
310310
typeof(ForwardDiff.Tag(tag, eltype(u))), eltype(u), 1
@@ -316,8 +316,8 @@ function HesVec(f, u::AbstractArray, p = nothing, t = nothing;
316316
error("Set autodiff to either AutoForwardDiff(), AutoZygote(), or AutoFiniteDiff()")
317317
end
318318

319-
outofplace = static_hasmethod(f, typeof((u,)))
320-
isinplace = static_hasmethod(f, typeof((u,)))
319+
outofplace = hasmethod(f, typeof((u,)))
320+
isinplace = hasmethod(f, typeof((u,)))
321321

322322
if !(isinplace) & !(outofplace)
323323
error("$f must have signature f(u).")
@@ -347,8 +347,8 @@ function HesVecGrad(f, u::AbstractArray, p = nothing, t = nothing;
347347
error("Set autodiff to either AutoForwardDiff(), or AutoFiniteDiff()")
348348
end
349349

350-
outofplace = static_hasmethod(f, typeof((u,)))
351-
isinplace = static_hasmethod(f, typeof((u, u)))
350+
outofplace = hasmethod(f, typeof((u,)))
351+
isinplace = hasmethod(f, typeof((u, u)))
352352

353353
if !(isinplace) & !(outofplace)
354354
error("$f must have signature f(u), or f(du, u).")

src/differentiation/vecjac_products.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function (L::AutoDiffVJP{<:AutoFiniteDiff})(dv, v, p, t; VJP_input = nothing)
152152
end
153153

154154
function Base.resize!(L::AutoDiffVJP, n::Integer)
155-
static_hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n)
155+
hasmethod(resize!, typeof((L.f, n))) && resize!(L.f, n)
156156
resize!(L.u, n)
157157
for v in L.cache
158158
resize!(v, n)

0 commit comments

Comments
 (0)