Possibly related issue https://github.com/sympy/sympy/issues/19774

Aaron Meurer

On Thu, Aug 6, 2020 at 5:28 PM Oscar Benjamin
<[email protected]> wrote:
>
> I'm not sure why that doesn't work but you can just use evalf directly:
>
> In [7]: expr
> Out[7]:
>     5/2  5/2
> 10⋅x   ⋅ℯ
> ────────────
>      3
>
> In [8]: expr.n()
> Out[8]:
>                   2.5
> 40.6083132023449⋅x
>
> Oscar
>
> On Thu, 6 Aug 2020 at 23:00, [email protected]
> <[email protected]> wrote:
> >
> > Hello,
> >
> > consider this trivial example:
> >
> > x = symbols("x")
> > expr = S(10) / 3 * exp(S(5) / 2) * x**(S(5) / 2)
> >
> > I would like to convert all rational numbers to float. I though it would be 
> > easy, for example:
> >
> > expr.replace(lambda e: e.is_Rational, lambda e: e.evalf())
> >
> > However, Rational numbers in the exponents are not converted. Why?
> >
> > Thanks in advance!
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sympy" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to [email protected].
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/sympy/6df11339-8e3a-4e12-bbde-ec893a2187cdn%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CAHVvXxSNSrBy6H7CO1jMm__JDZRt9HENsxfUmZaie5ANZax-RQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JZn4dyi1NrL8%3DgN4Gi%2B_SQ%3D%2BMcAGy2mjLDLnEnvUwc5w%40mail.gmail.com.

Reply via email to