Skip to content

Commit 6ea9552

Browse files
committed
Fix ambiguity and reorder broken test
1 parent 98bf0dc commit 6ea9552

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/differentials.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ derivative(O::Operation, idx) = derivative(O.op, (O.args...,), Val(idx))
9999
# Pre-defined derivatives
100100
import DiffRules, SpecialFunctions, NaNMath
101101
for (modu, fun, arity) DiffRules.diffrules()
102+
fun in [:*, :+] && continue # special
102103
for i 1:arity
103104
@eval function derivative(::typeof($modu.$fun), args::NTuple{$arity,Any}, ::Val{$i})
104105
M, f = $(modu, fun)
@@ -109,8 +110,8 @@ for (modu, fun, arity) ∈ DiffRules.diffrules()
109110
end
110111
end
111112

112-
derivative(::typeof(+), args::NTuple{N,Operation}, ::Val) where {N} = 1
113-
derivative(::typeof(*), args::NTuple{N,Operation}, ::Val{i}) where {N,i} = Operation(*, deleteat!(collect(args), i))
113+
derivative(::typeof(+), args::NTuple{N,Any}, ::Val) where {N} = 1
114+
derivative(::typeof(*), args::NTuple{N,Any}, ::Val{i}) where {N,i} = Operation(*, deleteat!(collect(args), i))
114115

115116
function count_order(x)
116117
@assert !(x isa Symbol) "The variable $x must have an order of differentiation that is greater or equal to 1!"

test/derivatives.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dsinsin = D(sin(sin(t)))
3131
d1 = D(sin(t)*t)
3232
d2 = D(sin(t)*cos(t))
3333
@test isequal(expand_derivatives(d1), t*cos(t)+sin(t))
34-
@test isequal(expand_derivatives(d2), simplify_constants(cos(t)*cos(t)+sin(t)*(-1*sin(t))))
34+
@test isequal(expand_derivatives(d2), simplify_constants(cos(t)*cos(t)+(sin(t)*-1)*sin(t)))
3535

3636
eqs = [0 ~ σ*(y-x),
3737
0 ~ x*-z)-y,

0 commit comments

Comments
 (0)