Skip to content

symbolics_to_sympy fais with BoundError when passing array variable #376

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

Open
lr4d opened this issue Sep 13, 2021 · 1 comment
Open

symbolics_to_sympy fais with BoundError when passing array variable #376

lr4d opened this issue Sep 13, 2021 · 1 comment

Comments

@lr4d
Copy link

lr4d commented Sep 13, 2021

e.g.

julia> using Symbolics, SymPy
julia> @variables s[1:2]
1-element Vector{Symbolics.Arr{Num, 1}}:
s[1:2]
julia> eq = s[2] + 3
3 + s[2]
julia> symbolics_to_sympy(eq)
ERROR: BoundsError
Stacktrace:
  [1] getindex(x::Sym, i::Int64)
    @ Base ./number.jl:96
  [2] symbolics_to_sympy(expr::SymbolicUtils.Term{Real, Nothing})
    @ Symbolics ~/.julia/packages/Symbolics/IKB6Q/src/init.jl:17
  [3] iterate
    @ ./generator.jl:47 [inlined]
  [4] collect_to!(dest::Vector{Int64}, itr::Base.Generator{Vector{Any}, typeof(symbolics_to_sympy)}, offs::Int64, st::Int64)
    @ Base ./array.jl:724
  [5] collect_to_with_first!(dest::Vector{Int64}, v1::Int64, itr::Base.Generator{Vector{Any}, typeof(symbolics_to_sympy)}, st::Int64)
    @ Base ./array.jl:702
  [6] _collect(c::Vector{Any}, itr::Base.Generator{Vector{Any}, typeof(symbolics_to_sympy)}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:696
  [7] collect_similar(cont::Vector{Any}, itr::Base.Generator{Vector{Any}, typeof(symbolics_to_sympy)})
    @ Base ./array.jl:606
  [8] map(f::Function, A::Vector{Any})
    @ Base ./abstractarray.jl:2294
  [9] symbolics_to_sympy(expr::Num)
    @ Symbolics ~/.julia/packages/Symbolics/IKB6Q/src/init.jl:13
 [10] top-level scope
    @ REPL[4]:1

Environment:
Julia 1.6.2

(@v1.6) pkg> status Symbolics
      Status `~/.julia/environments/v1.6/Project.toml`
  [0c5d862f] Symbolics v3.3.1

(@v1.6) pkg> status SymPy
      Status `~/.julia/environments/v1.6/Project.toml`
  [24249f21] SymPy v1.0.52

┆Issue is synchronized with this Trello card by Unito

@moble
Copy link
Contributor

moble commented Sep 17, 2021

A workaround would be to define

s = [Symbolics.variable(:s, i) for i in 1:2]

I don't think this should be necessary, though; see #379.

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

2 participants