Skip to content

Commit

Permalink
Added BasicSymbolic as input for function fed to derivative
Browse files Browse the repository at this point in the history
and fixed error report
  • Loading branch information
kapple19 committed Sep 4, 2024
1 parent fb0265e commit 6bd882b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/diff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ derivative(::typeof(+), args::NTuple{N,Any}, ::Val) where {N} = 1
derivative(::typeof(*), args::NTuple{N,Any}, ::Val{i}) where {N,i} = *(deleteat!(collect(args), i)...)
derivative(::typeof(one), args::Tuple{<:Any}, ::Val) = 0

derivative(f::Function, x::Num) = derivative(f(x), x)
derivative(::Function, x::Any) = TypeError(:derivative, "2nd argument", Num, typeof(x)) |> throw
derivative(f::Function, x::Union{Num, <:BasicSymbolic}) = derivative(f(x), x)
derivative(::Function, x::Any) = TypeError(:derivative, "2nd argument", Union{Num, <:BasicSymbolic}, x) |> throw

function count_order(x)
@assert !(x isa Symbol) "The variable $x must have an order of differentiation that is greater or equal to 1!"
Expand Down

0 comments on commit 6bd882b

Please sign in to comment.