m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
634 B

6 months ago
  1. from sympy.core.singleton import S
  2. from sympy.core.symbol import symbols
  3. from sympy.parsing.ast_parser import parse_expr
  4. from sympy.testing.pytest import raises
  5. from sympy.core.sympify import SympifyError
  6. def test_parse_expr():
  7. a, b = symbols('a, b')
  8. # tests issue_16393
  9. assert parse_expr('a + b', {}) == a + b
  10. raises(SympifyError, lambda: parse_expr('a + ', {}))
  11. # tests Transform.visit_Num
  12. assert parse_expr('1 + 2', {}) == S(3)
  13. assert parse_expr('1 + 2.0', {}) == S(3.0)
  14. # tests Transform.visit_Name
  15. assert parse_expr('Rational(1, 2)', {}) == S(1)/2
  16. assert parse_expr('a', {'a': a}) == a