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

SINDy basis does not print after construction #353

Open
cnrrobertson opened this issue May 18, 2022 · 4 comments
Open

SINDy basis does not print after construction #353

cnrrobertson opened this issue May 18, 2022 · 4 comments

Comments

@cnrrobertson
Copy link

Trying to construct a basis for nonlinear time continuous system and getting a method error. Most easily reproduced by following the basis creation in the example:

using DataDrivenDiffEq
using ModelingToolkit

@parameters t
@variables u[1:2](t)
Ψ = Basis([u; u[1]^2], u, independent_variable = t)

gives me:

Model ##Basis#291 with 3 Error showing value of type Basis:
ERROR: MethodError: no method matching Basis(::Vector{Equation}, ::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}, ::Vector{Any}, ::Vector{Any}, ::Vector{Any}, ::Num, ::Vector{Any}, ::DataDrivenDiffEq.var"#f#2", ::Symbol, ::Vector{Union{}}; checks=false)
Closest candidates are:
  Basis(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at ~/.julia/packages/DataDrivenDiffEq/XTH8l/src/basis/type.jl:54 got unsupported keyword argument "checks"
  Basis(::Vector{Equation}, ::Vector, ::Vector, ::Vector, ::Vector, ::Num, ::Vector, ::Function, ::Symbol, ::Vector{Basis}) at ~/.julia/packages/DataDrivenDiffEq/XTH8l/src/basis/type.jl:54 got unsupported keyword argument "checks"
  Basis(::AbstractVector{Equation}, ::AbstractVector; parameters, iv, controls, implicits, observed, name, simplify, linear_independent, eval_expression, kwargs...) at ~/.julia/packages/DataDrivenDiffEq/XTH8l/src/basis/type.jl:11

I've never had this issue before but its been a while since I've tried. Julia 1.7.2

@cnrrobertson
Copy link
Author

I aplogize, I should have included the full stacktrace. It seems like this is actually just a display error from ModelingToolkit.

Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/abstractsystem.jl:0 [inlined]
  [2] setproperties(obj::Basis, patch::NamedTuple{(:systems,), Tuple{Vector{Union{}}}})
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/abstractsystem.jl:266
  [3] set
    @ ~/.julia/packages/Setfield/AS2xF/src/lens.jl:122 [inlined]
  [4] macro expansion
    @ ~/.julia/packages/Setfield/AS2xF/src/sugar.jl:197 [inlined]
  [5] generate_connection_set!(connectionsets::Vector{ModelingToolkit.ConnectionSet}, sys::Basis, namespace::Nothing)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/connectors.jl:225
  [6] generate_connection_set!
    @ ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/connectors.jl:195 [inlined]
  [7] generate_connection_set
    @ ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/connectors.jl:190 [inlined]
  [8] n_extra_equations(sys::Basis)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/abstractsystem.jl:714
  [9] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, sys::Basis)
    @ ModelingToolkit ~/.julia/packages/ModelingToolkit/FqHcR/src/systems/abstractsystem.jl:746
 [10] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:266
 [11] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:510
 [12] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:259
 [13] display(d::REPL.REPLDisplay, x::Any)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:271
 [14] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [15] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [16] invokelatest
    @ ./essentials.jl:714 [inlined]
 [17] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:293
 [18] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:277
 [19] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:510
 [20] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:275
 [21] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLH
ok::Bool)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:846
 [22] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [23] invokelatest
    @ ./essentials.jl:714 [inlined]
 [24] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface,
    @ REPL.LineEdit ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl
 [25] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/REPL/src/REPL.jl:1232
 [26] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:423

The basis is created, but doesn't display in the REPL. The MethodError threw me off. It displays fine with print(Ψ)

@ChrisRackauckas
Copy link
Member

@YingboMa might this be the connection set printing?

@nxtruong
Copy link

nxtruong commented May 24, 2022

Got the same error. Even the Getting Started example (https://datadriven.sciml.ai/stable/examples/0_getting_started/) doesn't work. I also tried several other examples that use Basis (not necessarily SINDy), none worked due to the same error. My temporary solution is to implement SINDy from scratch, solved by Gurobi.

@nxtruong
Copy link

I didn't realize that the basis was created successfully, it's just its displaying in the REPL. So it works; the displaying error is annoying but harmless (I think).

@cnrrobertson cnrrobertson changed the title Can't construct basis for SINDy SINDy basis does not print after construction Oct 6, 2022
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

No branches or pull requests

3 participants