Casts from float64, int64, to symbolic types are missing
Opened this issue · 4 comments
orebas commented
I have any array of equations created by some other symbolic code, and it breaks when I try to substitute the value 1.0 for the rhs of an equation.
I just want a representation of the value 1.0, and I can't seem to create it in the obvious way (see below).
t = SymbolicUtils.BasicSymbolic{Real}(1.0)
ERROR: MethodError: no method matching SymbolicUtils.BasicSymbolic{Real}(::Float64)
Closest candidates are:
(::Type{SymbolicUtils.BasicSymbolic{T}} where T)(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
@ SymbolicUtils ~/.julia/packages/SymbolicUtils/qyMYa/src/types.jl:27
Stacktrace:
[1] top-level scope
@ REPL[18]:1
orebas commented
Here's a very short MWE, which is similar to what I'm trying to do:
using ModelingToolkit
@variables x,y,z
eqvec = [x ~ z, y~x^2+z]
rhs_vec = [e.rhs for e in eqvec]
#rhs_vec[1] = x
#rhs_vec[1] = x/x
rhs_vec[1] = 1.0
bowenszhu commented
Please use
SymbolicUtils.Term{Real}(identity, [1.0])
Sorry. This is a known issue, and we still haven't provided a simpler way.
orebas commented
Actually, I still get this error:
ERROR: MethodError: Cannot `convert` an object of type Num to an object of
type SymbolicUtils.BasicSymbolic{Real}
the "typeof" the expression you recommended seems to be "Num"
…On Thu, May 23, 2024 at 1:57 AM Bowen S. Zhu ***@***.***> wrote:
Please use
Symbolics.wrap(SymbolicUtils.Term(identity, [1.0]))
Sorry. This is a known issue, and we still haven't provided a simpler
constructor.
- JuliaSymbolics/Symbolics.jl#853
<JuliaSymbolics/Symbolics.jl#853>
—
Reply to this email directly, view it on GitHub
<#601 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK37HIUM647OGYB6OU43QOLZDWAMBAVCNFSM6AAAAABIE4KZZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRWGI4TGMJZGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
bowenszhu commented
Please remove Symbolics.wrap
if you used it.