Skip to content

Commit 3112fb1

Browse files
authored
fix convert(Variable, D(x)) (#412)
Fix #409
1 parent 107090f commit 3112fb1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/ModelingToolkit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function Base.convert(::Type{Variable},x::Operation)
7373
x.op
7474
elseif x.op isa Differential
7575
var = x.args[1].op
76-
rename(var,Symbol(var.name,,x.args[1].args[1].op.name))
76+
rename(var,Symbol(var.name,,x.op.x))
7777
else
7878
throw(error("This Operation is not a Variable"))
7979
end

test/derivatives.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,8 @@ tmp = beta * (alpha * exp(x1) * x2 ^ (alpha - 1) + 1 - delta) / x3
8686
# derivative w.r.t. x1 and x2
8787
t1 = ModelingToolkit.gradient(tmp, [x1, x2])
8888
@test_nowarn ModelingToolkit.gradient(t1[1], [beta])
89+
90+
@parameters t k
91+
@variables x(t)
92+
@derivatives D'~k
93+
@test convert(Variable, D(x)).name === :xˍk

0 commit comments

Comments
 (0)