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

Casts from float64, int64, to symbolic types are missing #601

Open
orebas opened this issue May 23, 2024 · 4 comments · May be fixed by #617
Open

Casts from float64, int64, to symbolic types are missing #601

orebas opened this issue May 23, 2024 · 4 comments · May be fixed by #617

Comments

@orebas
Copy link

orebas commented May 23, 2024

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
Copy link
Author

orebas commented May 23, 2024

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
Copy link
Member

Please use

SymbolicUtils.Term{Real}(identity, [1.0])

Sorry. This is a known issue, and we still haven't provided a simpler way.

@orebas
Copy link
Author

orebas commented May 23, 2024 via email

@bowenszhu
Copy link
Member

Please remove Symbolics.wrap if you used it.

@bowenszhu bowenszhu closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
@bowenszhu bowenszhu reopened this May 25, 2024
@bowenszhu bowenszhu linked a pull request Jun 18, 2024 that will close this issue
@bowenszhu bowenszhu linked a pull request Aug 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants