def test_conv10(): A = densematrix(1, 4, [Integer(1), Integer(2), Integer(3), Integer(4)]) assert A._sympy_() == sympy.Matrix(1, 4, [ sympy.Integer(1), sympy.Integer(2), sympy.Integer(3), sympy.Integer(4) ]) B = densematrix(4, 1, [Symbol("x"), Symbol("y"), Symbol("z"), Symbol("t")]) assert B._sympy_() == sympy.Matrix(4, 1, [ sympy.Symbol("x"), sympy.Symbol("y"), sympy.Symbol("z"), sympy.Symbol("t") ]) C = densematrix( 2, 2, [Integer(5), Symbol("x"), function_symbol("f", Symbol("x")), 1 + I]) assert C._sympy_() == sympy.Matrix( [[5, sympy.Symbol("x")], [sympy.Function("f")(sympy.Symbol("x")), 1 + sympy.I]])
def test_arit2(): x = Symbol("x") y = Symbol("y") assert x + x == Integer(2) * x assert x + x != Integer(3) * x assert x + y == y + x assert x + x == 2 * x assert x + x == x * 2 assert x + x + x == 3 * x assert x + y + x + x == 3 * x + y assert not x + x == 3 * x assert not x + x != 2 * x
def test_conv10b(): A = sympy.Matrix([[sympy.Symbol("x"), sympy.Symbol("y")], [sympy.Symbol("z"), sympy.Symbol("t")]]) assert sympify(A) == densematrix(2, 2, [Symbol("x"), Symbol("y"), Symbol("z"), Symbol("t")]) B = sympy.Matrix([[1, 2], [3, 4]]) assert sympify(B) == densematrix(2, 2, [Integer(1), Integer(2), Integer(3), Integer(4)]) C = sympy.Matrix([[7, sympy.Symbol("y")], [sympy.Function("g")(sympy.Symbol("z")), 3 + 2*sympy.I]]) assert sympify(C) == densematrix(2, 2, [Integer(7), Symbol("y"), function_symbol("g", Symbol("z")), 3 + 2*I])
def test_conv9b(): x = Symbol("x") y = Symbol("y") assert sympify(sympy.I) == I assert sympify(2*sympy.I+3) == 2*I+3 assert sympify(2*sympy.I/5+sympy.S(3)/5) == 2*I/5+Integer(3)/5 assert sympify(sympy.Symbol("x")*sympy.I + 3) == x*I+3 assert sympify(sympy.Symbol("x") + sympy.I*sympy.Symbol("y")) == x+I*y
def test_conv9(): x = Symbol("x") y = Symbol("y") assert (I)._sympy_() == sympy.I assert (2*I+3)._sympy_() == 2*sympy.I+3 assert (2*I/5+Integer(3)/5)._sympy_() == 2*sympy.I/5+sympy.S(3)/5 assert (x*I+3)._sympy_() == sympy.Symbol("x")*sympy.I + 3 assert (x+I*y)._sympy_() == sympy.Symbol("x") + sympy.I*sympy.Symbol("y")
def test_arit1(): x = Symbol("x") y = Symbol("y") e = x + y e = x * y e = Integer(2) * x e = 2 * x e = x + 1 e = 1 + x
def test_abs(): x = Symbol("x") e = abs(x) assert e == abs(x) assert e != cos(x) assert abs(5) == 5 assert abs(-5) == 5 assert abs(Integer(5)/3) == Integer(5)/3 assert abs(-Integer(5)/3) == Integer(5)/3 assert abs(Integer(5)/3+x) != Integer(5)/3 assert abs(Integer(5)/3+x) == abs(Integer(5)/3+x)
def test_arit6(): x = Symbol("x") y = Symbol("y") e = x + y assert str(e) == "x + y" or "y + x" e = x * y assert str(e) == "x*y" or "y*x" e = Integer(2) * x assert str(e) == "2*x" e = 2 * x assert str(e) == "2*x"
def test_bigfloat_invalid(): i = Integer(13333333333333333.5)
def test_integer_string(): i = Integer("133")
def test_smallfloat_valid(): i = Integer(7.5) assert str(i) == "7"
def test_conv5(): x = Integer(5) y = Integer(6) assert x._sympy_() == sympy.Integer(5) assert (x / y)._sympy_() == sympy.Integer(5) / sympy.Integer(6)
def test_integer_long(): i = Integer(123434444444444444444) assert str(i) == "123434444444444444444"
def test_sympify1(): assert sympify(1) == Integer(1) assert sympify(2) != Integer(1) assert sympify(-5) == Integer(-5) assert sympify(Integer(3)) == Integer(3)
def test_conv5b(): x = sympy.Integer(5) y = sympy.Integer(6) assert sympify(x) == Integer(5) assert sympify(x / y) == Integer(5) / Integer(6)
def test_integer_string(): raises(TypeError, lambda: Integer("133"))
def test_integer(): i = Integer(5) assert str(i) == "5"
def test_bigfloat_invalid(): raises(ValueError, lambda: Integer(13333333333333333.5))
def test_conv5(): x = Integer(5) y = Integer(6) assert x._sympy_() == sympy.Integer(5) assert (x/y)._sympy_() == sympy.Integer(5) / sympy.Integer(6)
def legendre(n, x): e = Integer(1)/(Integer(2)**n * fact(Integer(n))) * diff((x**2-1)**n, x, n) return e.expand()