You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use SA in BifurcationKit but I recently noticed that the push! is type unstable. If I remove StructArray in here in ContResult, the TI disappear. Am I wrongly using your package?
using Revise
using BifurcationKit
functionFsl!(out, X, p)
(;μ, c ) = p
x, y = X
ua = x^2+ y^2
out[1] = μ * x - y - x * ua * c
out[2] = x + μ * y - y * ua * c
out
endfunctionJFsl!(J, X, p)
(;μ, c) = p
x, y = X
ua = x^2+ y^2
J[1, 1] = μ - c * (ua +2x^2)
J[1, 2] =-1-2c * x * y
J[2, 1] =1-2c * x * y
J[2, 2] = μ - c * (ua +2y^2)
J
endJFsl(x,p) =JFsl!(zeros(2,2),x,p)
prob =BifurcationProblem(Fsl!, zeros(2), (μ=0-.1, c=1.), (@optic _.μ); J! = JFsl!, J = JFsl)
opts =ContinuationPar(p_max =2., detect_bifurcation =0, detect_fold=false)
br =@timecontinuation(prob, PALC(), opts)
@profview (for _=1:10000; continuation(prob, PALC(), ContinuationPar(p_max =2., detect_bifurcation =0, detect_fold=false)); end
Having an MWE would make understanding/fixing this issue more feasible...
In general, StructArrays tries to be very careful with type stability, and a typical push! call is definitely stable:
julia> A =StructArray(x=[1,2,3], y=[:a, :b, :c])
3-element StructArray(::Vector{Int64}, ::Vector{Symbol}) with eltype @NamedTuple{x::Int64, y::Symbol}:
(x =1, y =:a)
(x =2, y =:b)
(x =3, y =:c)
julia>@code_warntypepush!(A, (x=4, y=:d))
MethodInstance forpush!(::StructVector{@NamedTuple{x::Int64, y::Symbol}, @NamedTuple{x::Vector{Int64}, y::Vector{Symbol}}, Int64}, ::@NamedTuple{x::Int64, y::Symbol})
from push!(s::StructVector{T}, vals) where T @ StructArrays ~/.julia/packages/StructArrays/n5wxA/src/structarray.jl:384
Static Parameters
T =@NamedTuple{x::Int64, y::Symbol}
Arguments
#self#::Core.Const(push!)
s::StructVector{@NamedTuple{x::Int64, y::Symbol}, @NamedTuple{x::Vector{Int64}, y::Vector{Symbol}}, Int64}
vals::@NamedTuple{x::Int64, y::Symbol}
Locals
valsT::@NamedTuple{x::Int64, y::Symbol}
Body::StructVector{@NamedTuple{x::Int64, y::Symbol}, @NamedTuple{x::Vector{Int64}, y::Vector{Symbol}}, Int64}1 ─ (valsT = StructArrays.maybe_convert_elt($(Expr(:static_parameter, 1)), vals))
│ StructArrays.foreachfield(StructArrays.push!, s, valsT)
└── return s
Activity
aplavin commentedon Apr 26, 2025
Having an MWE would make understanding/fixing this issue more feasible...
In general, StructArrays tries to be very careful with type stability, and a typical
push!call is definitely stable:rveltz commentedon Apr 27, 2025
I edited the code to make it functional, sorry for the mistake
aplavin commentedon Apr 27, 2025
I mean, something more minimal would be of a great help. Presumably, just two steps needed to reproduce the instability:
push!with the structarray and an object.Someone may find time to debug the current example as-is, but having a more minimal one would lead to a faster fix.