diff --git a/ext/DataInterpolationsSymbolicsExt.jl b/ext/DataInterpolationsSymbolicsExt.jl index 2341745b..2a96bbe7 100644 --- a/ext/DataInterpolationsSymbolicsExt.jl +++ b/ext/DataInterpolationsSymbolicsExt.jl @@ -22,7 +22,7 @@ end SymbolicUtils.promote_symtype(::typeof(derivative), _...) = Real function Symbolics.derivative(interp::AbstractInterpolation, args::NTuple{1, Any}, ::Val{1}) - derivative(interp, Num(args[1])) + Symbolics.unwrap(derivative(interp, Symbolics.wrap(args[1]))) end end # module diff --git a/test/derivative_tests.jl b/test/derivative_tests.jl index 7501d096..abf5002e 100644 --- a/test/derivative_tests.jl +++ b/test/derivative_tests.jl @@ -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))