diff --git a/setup.py b/setup.py index 346e1db0..33365e5b 100644 --- a/setup.py +++ b/setup.py @@ -226,6 +226,7 @@ def finalize_options(self): url="https://github.com/symengine/symengine.py", python_requires='>=3.7,<4', zip_safe=False, + packages=['symengine'], cmdclass = cmdclass, classifiers=[ 'License :: OSI Approved :: MIT License', diff --git a/symengine/lib/symengine_wrapper.pyx b/symengine/lib/symengine_wrapper.pyx index b6473b16..2e7ea207 100644 --- a/symengine/lib/symengine_wrapper.pyx +++ b/symengine/lib/symengine_wrapper.pyx @@ -294,9 +294,9 @@ def sympy2symengine(a, raise_error=False): if a._prec > 53: return RealMPFR(str(a), a._prec) else: - return RealDouble(float(str(a))) + return RealDouble(float(a)) ELSE: - return RealDouble(float(str(a))) + return RealDouble(float(a)) elif a is sympy.I: return I elif a is sympy.E: @@ -1902,7 +1902,7 @@ class RealDouble(Float): def _sympy_(Basic self): import sympy - return sympy.Float(deref(self.thisptr).__str__().decode("utf-8")) + return sympy.Float(float(self)) def _sage_(Basic self): import sage.all as sage diff --git a/symengine/tests/test_sympy_conv.py b/symengine/tests/test_sympy_conv.py index ee070a81..67253637 100644 --- a/symengine/tests/test_sympy_conv.py +++ b/symengine/tests/test_sympy_conv.py @@ -3,7 +3,7 @@ exp, gamma, have_mpfr, have_mpc, DenseMatrix, sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, acsc, asec, sinh, cosh, tanh, coth, asinh, acosh, atanh, acoth, Add, Mul, Pow, diff, GoldenRatio, - Catalan, EulerGamma, UnevaluatedExpr) + Catalan, EulerGamma, UnevaluatedExpr, RealDouble) from symengine.lib.symengine_wrapper import (Subs, Derivative, RealMPFR, ComplexMPC, PyNumber, Function, LambertW, zeta, dirichlet_eta, KroneckerDelta, LeviCivita, erf, erfc, lowergamma, uppergamma, @@ -515,7 +515,7 @@ def test_zeta(): e1 = sympy.zeta(sympy.Symbol("x"), sympy.Symbol("y")) e2 = zeta(x, y) assert sympify(e1) == e2 - assert e2._sympy_() == e1 + assert e2._sympy_() == e1 @unittest.skipIf(not have_sympy, "SymPy not installed") @@ -796,3 +796,13 @@ def test_construct_dense_matrix(): B = DenseMatrix(A) assert B.shape == (2, 2) assert list(B) == [1, 2, 3, 5] + + +@unittest.skipIf(not have_sympy, "SymPy not installed") +def test_conv_doubles(): + f = 4.347249999999999 + a = sympify(f) + assert isinstance(a, RealDouble) + assert sympify(a._sympy_()) == a + assert float(a) == f + assert float(a._sympy_()) == f