+ @_with_sympy
+ def test_fromsympy(self):
+ sp_x, sp_y = sympy.symbols('x y')
+ self.assertEqual(Expression.fromsympy(sp_x), self.x)
+ self.assertEqual(Expression.fromsympy(sympy.Rational(22, 7)), self.pi)
+ self.assertEqual(Expression.fromsympy(sp_x - 2*sp_y + 3), self.expr)
+ with self.assertRaises(ValueError):
+ Expression.fromsympy(sp_x*sp_y)
+
+ @_with_sympy
+ def test_tosympy(self):
+ sp_x, sp_y = sympy.symbols('x y')
+ self.assertEqual(self.x.tosympy(), sp_x)
+ self.assertEqual(self.pi.tosympy(), sympy.Rational(22, 7))
+ self.assertEqual(self.expr.tosympy(), sp_x - 2*sp_y + 3)
+