-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from sathvikbhagavan/sb/inference
refactor: collect parameters such that they are type stable
- Loading branch information
Showing
4 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,52 @@ | ||
using DataInterpolations | ||
u = 2.0collect(1:10) | ||
t = 1.0collect(1:10) | ||
@inferred LinearInterpolation(u, t) | ||
A = LinearInterpolation(u, t) | ||
using Symbolics | ||
|
||
for i in 1:10 | ||
@test u[i] == A.u[i] | ||
end | ||
@testset "Interface" begin | ||
u = 2.0collect(1:10) | ||
t = 1.0collect(1:10) | ||
A = LinearInterpolation(u, t) | ||
|
||
for i in 1:10 | ||
@test u[i] == A.u[i] | ||
end | ||
|
||
for i in 1:10 | ||
@test t[i] == A.t[i] | ||
for i in 1:10 | ||
@test t[i] == A.t[i] | ||
end | ||
end | ||
|
||
using Symbolics | ||
u = 2.0collect(1:10) | ||
t = 1.0collect(1:10) | ||
A = LinearInterpolation(u, t) | ||
@testset "Symbolics" begin | ||
u = 2.0collect(1:10) | ||
t = 1.0collect(1:10) | ||
A = LinearInterpolation(u, t) | ||
@variables t x(t) | ||
substitute(A(t), Dict(t => x)) | ||
end | ||
|
||
@variables t x(t) | ||
substitute(A(t), Dict(t => x)) | ||
@testset "Type Inference" begin | ||
u = 2.0collect(1:10) | ||
t = 1.0collect(1:10) | ||
methods = [ | ||
ConstantInterpolation, LinearInterpolation, | ||
QuadraticInterpolation, LagrangeInterpolation, | ||
QuadraticSpline, CubicSpline, AkimaInterpolation | ||
] | ||
@testset "$method" for method in methods | ||
@inferred method(u, t) | ||
end | ||
@testset "BSplineInterpolation" begin | ||
@inferred BSplineInterpolation(u, t, 3, :Uniform, :Uniform) | ||
@inferred BSplineInterpolation(u, t, 3, :ArcLen, :Average) | ||
end | ||
@testset "BSplineApprox" begin | ||
@inferred BSplineApprox(u, t, 3, 5, :Uniform, :Uniform) | ||
@inferred BSplineApprox(u, t, 3, 5, :ArcLen, :Average) | ||
end | ||
du = ones(10) | ||
ddu = zeros(10) | ||
@testset "Hermite Splines" begin | ||
@inferred CubicHermiteSpline(du, u, t) | ||
@inferred PCHIPInterpolation(u, t) | ||
@inferred QuinticHermiteSpline(ddu, du, u, t) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters