JuliaSymbolics/SymbolicUtils.jl

Conversion from `LiteralReal` to `Real`

MilesCranmer opened this issue · 1 comments

Is there a way to convert an expression of type BasicSymbolic{LiteralReal} to type BasicSymbolic{Real}? If you point me in the right direction I could add this

shashi commented

There's no way right now, you'd have to simply add a function to do that. Maybe use

function literaltoreal(x)
  if issym(x)
      Sym{Real}(nameof(x))
  elseif istree(x) && symtype(x) <: LiteralReal
      similarterm(x, operation(x), arguments(x), Real; ...)
  else
  x
  end
end
# finally walk and apply
Rewriters.Postwalk(literaltoreal)(x)