-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce idx_prev to use as iguess #273
Conversation
Quick benchmark: using DataInterpolations
using BenchmarkTools
N = 1000
u = rand(N)
t = cumsum(rand(N))
itp = LinearInterpolation(u, t)
t_eval = range(first(t), last(t), length = 10000)
@btime itp.(t_eval)
# old: 276.000 μs (3 allocations: 78.25 KiB)
# new: 166.600 μs (3 allocations: 78.27 KiB) So the better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Can you add some tests to check whether idx_prev
is properly set?
test/interpolation_tests.jl
Outdated
for t in range(first(A.t), last(A.t); length = 2 * length(A.t) - 1) | ||
A(t) | ||
if hasproperty(A, :idx_prev) | ||
@test abs(A.idx_prev[] - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this test be written with equality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the kwargs of the new function get_idx
show, the index is obtained in several slightly different ways. Therefore it is not possible to test the index with equality in an interpolation method agnostic way :/
@@ -35,6 +36,11 @@ function test_derivatives(method, u, t; args = [], kwargs = [], name::String) | |||
adiff2 = derivative(func, _t, 2) | |||
@test isapprox(fdiff, adiff, atol = 1e-8) | |||
@test isapprox(fdiff2, adiff2, atol = 1e-8) | |||
# Cached index | |||
if hasproperty(func, :idx_prev) | |||
@test abs(func.idx_prev[] - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this test be written with equality?
@ChrisRackauckas, can you approve CI? |
Fixes half of #271
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.