|
1 | 1 | from symengine import (Symbol, Integer, sympify, SympifyError, log,
|
2 | 2 | function_symbol, I, E, pi, oo, zoo, nan, true, false,
|
3 |
| - exp, gamma, have_mpfr, have_mpc, DenseMatrix, sin, cos, tan, cot, |
| 3 | + exp, gamma, have_mpfr, have_mpc, DenseMatrix, Dummy, sin, cos, tan, cot, |
4 | 4 | csc, sec, asin, acos, atan, acot, acsc, asec, sinh, cosh, tanh, coth,
|
5 | 5 | asinh, acosh, atanh, acoth, atan2, Add, Mul, Pow, diff, GoldenRatio,
|
6 | 6 | Catalan, EulerGamma, UnevaluatedExpr, RealDouble)
|
@@ -833,3 +833,24 @@ def test_conv_large_integers():
|
833 | 833 | if have_sympy:
|
834 | 834 | c = a._sympy_()
|
835 | 835 | d = sympify(c)
|
| 836 | + |
| 837 | + |
| 838 | +def _check_sympy_roundtrip(arg): |
| 839 | + arg_sy1 = sympy.sympify(arg) |
| 840 | + arg_se2 = sympify(arg_sy1) |
| 841 | + assert arg == arg_se2 |
| 842 | + arg_sy2 = sympy.sympify(arg_se2) |
| 843 | + assert arg_sy2 == arg_sy1 |
| 844 | + arg_se3 = sympify(arg_sy2) |
| 845 | + assert arg_se3 == arg |
| 846 | + |
| 847 | + |
| 848 | +@unittest.skipIf(not have_sympy, "SymPy not installed") |
| 849 | +def test_sympy_roundtrip(): |
| 850 | + x = Symbol("x") |
| 851 | + y = Symbol("y") |
| 852 | + d = Dummy("d") |
| 853 | + _check_sympy_roundtrip(x) |
| 854 | + _check_sympy_roundtrip(x+y) |
| 855 | + _check_sympy_roundtrip(x**y) |
| 856 | + _check_sympy_roundtrip(d) |
0 commit comments