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

towards BifurcationKit @0.4 #3102

Merged
merged 11 commits into from
Oct 24, 2024
Merged

towards BifurcationKit @0.4 #3102

merged 11 commits into from
Oct 24, 2024

Conversation

rveltz
Copy link
Contributor

@rveltz rveltz commented Oct 7, 2024

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@ChrisRackauckas
Copy link
Member

AssertionError: lens isa Int || lens isa AllOpticTypes @rveltz do you know what this is?

@rveltz
Copy link
Contributor Author

rveltz commented Oct 13, 2024

Yes it is to ensure that the parameter axis is an int or an @optic (from accessors.jl)

@rveltz
Copy link
Contributor Author

rveltz commented Oct 13, 2024

Note that you don't need setfield anymore and it is re exported by BK. Not sure why you put it back

@ChrisRackauckas
Copy link
Member

LoadError: UndefVarError:@lensnot defined inMain.var"##BifurcationKit Extension Test#294"` I think doing what you are saying leads to this error?

@rveltz
Copy link
Contributor Author

rveltz commented Oct 23, 2024

I am confused. In [email protected] I replaced Setfield by Accessors. They should not be any @lens anywhere in the code

AssertionError: lens isa Int || lens isa AllOpticTypes @rveltz do you know what this is?

Yes. It is to allow to pass @optic _.bla or an Int as a parameter axis

@rveltz
Copy link
Contributor Author

rveltz commented Oct 23, 2024

replace the line https://github.com/SciML/ModelingToolkit.jl/blob/master/test/extensions/bifurcationkit.jl#L39 with BifurcationKit.@optic _[1] and it should work

@ChrisRackauckas
Copy link
Member

  LoadError: MethodError: no method matching (::Main.var"##BifurcationKit Extension Test#289".var"#2#6")(::Vector{Float64}, ::Float64; iter::BifurcationKit.ContIterable{BifurcationKit.EquilibriumCont, BifurcationKit.BifurcationProblem{BifurcationKit.BifFunction{Main.var"##BifurcationKit Extension Test#289".var"#f_BK#5", BifurcationKit.var"#8#24", Nothing, BifurcationKit.var"#6#22", Nothing, BifurcationKit.var"#11#28"{BifurcationKit.var"#d1Fad#26"}, BifurcationKit.var"#13#30", BifurcationKit.var"#15#32", BifurcationKit.var"#17#34", Bool, Float64}, Vector{Float64}, Vector{Float64}, Accessors.IndexLens{Tuple{Int64}}, typeof(BifurcationKit.plot_default), Main.var"##BifurcationKit Extension Test#289".var"#2#6", typeof(BifurcationKit.save_solution_default)}, BifurcationKit.PALC{BifurcationKit.Secant, BifurcationKit.MatrixBLS{BifurcationKit.DefaultLS}, Float64, BifurcationKit.DotTheta{BifurcationKit.var"#279#281", BifurcationKit.var"#280#282"}}, Float64, BifurcationKit.DefaultLS, BifurcationKit.DefaultEig{typeof(real)}, typeof(LinearAlgebra.norm), typeof(BifurcationKit.finalise_default), typeof(BifurcationKit.cb_default), Nothing}, state::BifurcationKit.ContState{BifurcationKit.BorderedArray{Vector{Float64}, Float64}, Float64, Vector{ComplexF64}, Matrix{ComplexF64}, Tuple{Nothing, Nothing}})
  
  Closest candidates are:
    (::Main.var"##BifurcationKit Extension Test#289".var"#2#6")(::Any, ::Any) got unsupported keyword arguments "iter", "state"
     @ Main.var"##BifurcationKit Extension Test#289" ~/work/ModelingToolkit.jl/ModelingToolkit.jl/test/extensions/bifurcationkit.jl:40

Is this from some anonymous function generated by optic? I have no idea what's going on here or what @optic even is: is there a simpler way to write this?

@rveltz
Copy link
Contributor Author

rveltz commented Oct 24, 2024

What caused it? A test?

I dont see the line number of the closest candidates. I bet this is coming from

 record_from_solution = (x, p) -> x[plot_idx]
 # which is now (as it should)
record_from_solution = (x, p; k...) -> x[plot_idx]

When I submitted the PR, I made sure that the current MTK doc-page worked, so I am surprised by all this.

@rveltz
Copy link
Contributor Author

rveltz commented Oct 24, 2024

I have no idea what's going on here or what @optic even is: is there a simpler way to write this?

An optic is from Accessors.jl
It allows to specify a parameter axis. For example, if you pass a named typle as a parameter

pars = (a=1., b=2.)

and would like to continue the solutions wrt to a, you can pass @optic _.a. If you pass an array and want to continue wrt to the first parameter, you can pass @optic _[1]. In this last case, you could pass directly 1 to continuation. See also bifurcationkit/BifurcationKit.jl#159

@ChrisRackauckas ChrisRackauckas merged commit be393fd into SciML:master Oct 24, 2024
35 of 39 checks passed
@ChrisRackauckas
Copy link
Member

Awesome, thanks so much!

@rveltz
Copy link
Contributor Author

rveltz commented Oct 24, 2024

No problem. I am embarassed, I thought my PR would have been more straightforward

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