Skip to content
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

refactor: collect parameters such that they are type stable #308

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

sathvikbhagavan
Copy link
Member

Followup of #304 - Checked type inference of all methods and found some instabilities like:

julia> @inferred CubicSpline(u, t)
ERROR: return type CubicSpline{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64} does not match inferred return type CubicSpline{ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, ReadOnlyArrays.ReadOnlyVector{Float64, Vector{Float64}}, _A, _B, Vector{Float64}, Vector{Float64}, Float64} where {_A, _B}
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] top-level scope
   @ REPL[6]:1

Analyzed using Cthulhu and found instability was in the construction of parameter cache.

I have fixed and added all the inference tests.

src/online.jl Outdated
@@ -68,7 +68,7 @@ function append!(
append!(A.t.parent, t)
parameters = quadratic_interpolation_parameters.(
Ref(A.u), Ref(A.t), (length_old - 1):(length(A.t) - 2))
l₀, l₁, l₂ = collect.(eachrow(hcat(collect.(parameters)...)))
l₀, l₁, l₂ = collect.(eachrow(reduce(hcat, collect.(parameters))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l₀, l₁, l₂ = collect.(eachrow(reduce(hcat, collect.(parameters))))
l₀, l₁, l₂ = collect.(eachrow(stack(collect.(parameters)))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 826f0a7

@ChrisRackauckas ChrisRackauckas merged commit d1cc354 into SciML:master Jul 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants