Skip to content

Commit

Permalink
Merge pull request #570 from JuliaSymbolics/s/fix-diff-error2
Browse files Browse the repository at this point in the history
Fix one more wrong error in array differentiation
  • Loading branch information
shashi committed Apr 7, 2022
2 parents 8494959 + c7971ac commit 17b9aa5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ function occursin_info(x, expr)
!occursin(first(arguments(x)), first(arguments(expr)))
return false
end

if is_scalar_indexed(expr) && !is_scalar_indexed(x) && !occursin(x, expr)
return false
end

!istree(expr) && return false
if isequal(x, expr)
true
Expand Down
4 changes: 3 additions & 1 deletion test/diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,10 @@ end

# make sure derivative(x[1](t), y) does not fail
let
@variables t
@variables t a(t)
vars = collect(@variables(x[1:1](t))[1])
ps = collect(@variables(ps[1:1])[1])
@test Symbolics.derivative(ps[1], vars[1]) == 0
@test Symbolics.derivative(ps[1], a) == 0
@test Symbolics.derivative(x[1], a) == 0
end

0 comments on commit 17b9aa5

Please sign in to comment.