test_abstract_nodes.py 451 B

1234567891011121314
  1. from sympy.core.symbol import symbols
  2. from sympy.codegen.abstract_nodes import List
  3. def test_List():
  4. l = List(2, 3, 4)
  5. assert l == List(2, 3, 4)
  6. assert str(l) == "[2, 3, 4]"
  7. x, y, z = symbols('x y z')
  8. l = List(x**2,y**3,z**4)
  9. # contrary to python's built-in list, we can call e.g. "replace" on List.
  10. m = l.replace(lambda arg: arg.is_Pow and arg.exp>2, lambda p: p.base-p.exp)
  11. assert m == [x**2, y-3, z-4]
  12. hash(m)