Skip to content

Commit da2d2fc

Browse files
committed
Parse an expression of a tuple to Differentials
1 parent c9aa240 commit da2d2fc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/differentials.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ _repeat_apply(f, n) = n == 1 ? f : f ∘ _repeat_apply(f, n-1)
6161
function _differential_macro(x)
6262
ex = Expr(:block)
6363
lhss = Symbol[]
64+
x = x isa Tuple && first(x).head == :tuple ? first(x).args : x # tuple handling
6465
x = flatten_expr!(x)
6566
for di in x
66-
@assert di isa Expr && di.args[1] == :~ "@derivatives expects a form that looks like `@derivatives D''~t E'~t`"
67+
@assert di isa Expr && di.args[1] == :~ "@derivatives expects a form that looks like `@derivatives D''~t E'~t` or `@derivatives (D''~t), (E'~t)`"
6768
lhs = di.args[2]
6869
rhs = di.args[3]
6970
order, lhs = count_order(lhs)

test/derivatives.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ using Test
66
@variables x(t) y(t) z(t)
77
@derivatives D'~t D2''~t
88

9+
@test @macroexpand(@derivatives D'~t D2''~t) == @macroexpand(@derivatives (D'~t), (D2''~t))
10+
911
@test isequal(expand_derivatives(D(t)), 1)
1012
@test isequal(expand_derivatives(D(D(t))), 0)
1113

0 commit comments

Comments
 (0)