Skip to content

Commit

Permalink
test: add test for symbolic derivative
Browse files Browse the repository at this point in the history
  • Loading branch information
sathvikbhagavan committed Oct 13, 2023
1 parent a9719ea commit ae03aec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/derivative_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,13 @@ expr = A(ω)
derivexpr = expand_derivatives(substitute(D(A(ω)), Dict=> 0.5τ)))
symfunc = Symbolics.build_function(derivexpr, τ; expression = Val{false})
@test symfunc(0.5) == 0.5 * 3

u = [0.0, 1.5, 0.0]
t = [0.0, 0.5, 1.0]
@variables τ
D = Symbolics.Differential(τ)
f = LinearInterpolation(u, t)
df = expand_derivatives(D(f(τ)))
symfunc = Symbolics.build_function(df, τ; expression = Val{false})
ts = 0.0:0.1:1.0
@test all(map(ti -> symfunc(ti) == derivative(f, ti), ts))

0 comments on commit ae03aec

Please sign in to comment.