Converts rational numbers in expr into floats. :param expr: Sympy expression in which rational numbers need to be converterd into floats. :type expr: sympy.Expression :return: expression in which rational numbers have been replaced with floats. :rtype: sympy.
(expr)
| 1862 | return expr |
| 1863 | |
| 1864 | def rational2float(expr): |
| 1865 | """ |
| 1866 | Converts rational numbers in expr into floats. |
| 1867 | |
| 1868 | :param expr: Sympy expression in which rational numbers need to be |
| 1869 | converterd into floats. |
| 1870 | :type expr: sympy.Expression |
| 1871 | |
| 1872 | :return: expression in which rational numbers have been replaced with floats. |
| 1873 | :rtype: sympy.Expression |
| 1874 | """ |
| 1875 | try: |
| 1876 | for atom in expr.atoms(): |
| 1877 | if isinstance(atom, sp.core.numbers.Rational) and not isinstance(atom, sp.core.numbers.Integer): |
| 1878 | expr = expr.xreplace({atom: sp.Float(atom, ini.disp)}) |
| 1879 | except AttributeError: |
| 1880 | pass |
| 1881 | return expr |
| 1882 | |
| 1883 | def roundN(expr, numeric=False): |
| 1884 | """ |