Skip to content

Commit

Permalink
Implement @YingboMa's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Mar 12, 2024
1 parent ec67b9e commit a7c9375
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ julia> D3 = Differential(x)^3 # 3rd order differential operator
"""
struct Differential <: Operator
"""The variable or expression to differentiate with respect to."""
x::BasicSymbolic
x
function Differential(x)
vx = value(x)
vx isa BasicSymbolic && SymbolicUtils.exprtype(vx) == SymbolicUtils.SYM ||
throw(ArgumentError("Must differentiate with respect to a symbol, got $vx"))
istree(vx) && throw(ArgumentError("Cannot differentiate with respect to $vx"))
new(vx)
end
end
Expand Down

0 comments on commit a7c9375

Please sign in to comment.