Skip to content

Commit 55b5230

Browse files
committed
fix build function for y^-1
1 parent 914d34f commit 55b5230

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/direct.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ function toexpr(O::Term)
222222
end
223223
if O.op === (^)
224224
if length(O.args) > 1 && O.args[2] isa Number && O.args[2] < 0
225-
return Expr(:call, :^, Expr(:call, :inv, toexpr(O.args[1])), -(O.args[2].value))
225+
return Expr(:call, ^, Expr(:call, inv, toexpr(O.args[1])), -(O.args[2]))
226226
end
227227
end
228228
return Expr(:call, O.op, toexpr.(O.args)...)

test/direct.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,17 @@ f = eval(f2)
141141
f(out,[1.0,2,3])
142142
@test all(out .== o1)
143143

144+
# y ^ -1 test
145+
g = let
146+
f(x,y) = x/y
147+
@variables x y
148+
ex = expand_derivatives(Differential(x)(f(x, y)))
149+
func_ex = build_function(ex, x, y)
150+
eval(func_ex)
151+
end
152+
153+
@test g(42,4) == 1/4
154+
144155
function test_worldage()
145156
@variables x y z
146157
eqs = [(y-x)^2,

0 commit comments

Comments
 (0)