Skip to content

Commit

Permalink
Fix ambiguity and reorder broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Feb 7, 2020
1 parent 98bf0dc commit 6ea9552
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/differentials.jl
Expand Up @@ -99,6 +99,7 @@ derivative(O::Operation, idx) = derivative(O.op, (O.args...,), Val(idx))
# Pre-defined derivatives
import DiffRules, SpecialFunctions, NaNMath
for (modu, fun, arity) DiffRules.diffrules()
fun in [:*, :+] && continue # special
for i 1:arity
@eval function derivative(::typeof($modu.$fun), args::NTuple{$arity,Any}, ::Val{$i})
M, f = $(modu, fun)
Expand All @@ -109,8 +110,8 @@ for (modu, fun, arity) ∈ DiffRules.diffrules()
end
end

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

function count_order(x)
@assert !(x isa Symbol) "The variable $x must have an order of differentiation that is greater or equal to 1!"
Expand Down
2 changes: 1 addition & 1 deletion test/derivatives.jl
Expand Up @@ -31,7 +31,7 @@ dsinsin = D(sin(sin(t)))
d1 = D(sin(t)*t)
d2 = D(sin(t)*cos(t))
@test isequal(expand_derivatives(d1), t*cos(t)+sin(t))
@test isequal(expand_derivatives(d2), simplify_constants(cos(t)*cos(t)+sin(t)*(-1*sin(t))))
@test isequal(expand_derivatives(d2), simplify_constants(cos(t)*cos(t)+(sin(t)*-1)*sin(t)))

eqs = [0 ~ σ*(y-x),
0 ~ x*-z)-y,
Expand Down

0 comments on commit 6ea9552

Please sign in to comment.