test_class_structure.py 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. from sympy.diffgeom import Manifold, Patch, CoordSystem, Point
  2. from sympy.core.function import Function
  3. from sympy.core.symbol import symbols
  4. from sympy.testing.pytest import warns_deprecated_sympy
  5. m = Manifold('m', 2)
  6. p = Patch('p', m)
  7. a, b = symbols('a b')
  8. cs = CoordSystem('cs', p, [a, b])
  9. x, y = symbols('x y')
  10. f = Function('f')
  11. s1, s2 = cs.coord_functions()
  12. v1, v2 = cs.base_vectors()
  13. f1, f2 = cs.base_oneforms()
  14. def test_point():
  15. point = Point(cs, [x, y])
  16. assert point != Point(cs, [2, y])
  17. #TODO assert point.subs(x, 2) == Point(cs, [2, y])
  18. #TODO assert point.free_symbols == set([x, y])
  19. def test_subs():
  20. assert s1.subs(s1, s2) == s2
  21. assert v1.subs(v1, v2) == v2
  22. assert f1.subs(f1, f2) == f2
  23. assert (x*f(s1) + y).subs(s1, s2) == x*f(s2) + y
  24. assert (f(s1)*v1).subs(v1, v2) == f(s1)*v2
  25. assert (y*f(s1)*f1).subs(f1, f2) == y*f(s1)*f2
  26. def test_deprecated():
  27. with warns_deprecated_sympy():
  28. cs_wname = CoordSystem('cs', p, ['a', 'b'])
  29. assert cs_wname == cs_wname.func(*cs_wname.args)