MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / rational2float

Function rational2float

SLiCAP/SLiCAPmath.py:1864–1881  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1862 return expr
1863
1864def 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
1883def roundN(expr, numeric=False):
1884 """

Callers 1

roundNFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected