def testInteger(self): self.compare(mathics.Integer(0), sympy.Integer(0)) self.compare(mathics.Integer(1), sympy.Integer(1)) n = random.randint(-sys.maxsize, sys.maxsize) self.compare(mathics.Integer(n), sympy.Integer(n)) n = random.randint(sys.maxsize, sys.maxsize * sys.maxsize) self.compare(mathics.Integer(n), sympy.Integer(n))
def testComplex(self): self.compare( mathics.Complex(mathics.Real('1.0'), mathics.Real('1.0')), sympy.Add(sympy.Float('1.0'), sympy.Float('1.0') * sympy.I)) self.compare(mathics.Complex(mathics.Integer(0), mathics.Integer(1)), sympy.I) self.compare(mathics.Complex(mathics.Integer(-1), mathics.Integer(1)), sympy.Integer(-1) + sympy.I)
def testComplex(self): self.compare( mathics.Complex(mathics.Real("1.0"), mathics.Real("1.0")), sympy.Add(sympy.Float("1.0"), sympy.Float("1.0") * sympy.I), ) self.compare(mathics.Complex(mathics.Integer(0), mathics.Integer(1)), sympy.I) self.compare( mathics.Complex(mathics.Integer(-1), mathics.Integer(1)), sympy.Integer(-1) + sympy.I, )
def testAdd(self): self.compare( mathics.Expression( 'Plus', mathics.Integer(1), mathics.Symbol('Global`x')), sympy.Add( sympy.Integer(1), sympy.Symbol('_Mathics_User_Global`x')))
def testDerivative2(self): kwargs = {'converted_functions': set(['Global`f'])} head = mathics.Expression( mathics.Expression('System`Derivative', mathics.Integer(1), mathics.Integer(0)), mathics.Symbol('Global`f')) expr = mathics.Expression(head, mathics.Symbol('Global`x'), mathics.Symbol('Global`y')) sfxy = sympy.Function(str('_Mathics_User_Global`f'))( sympy.Symbol('_Mathics_User_Global`x'), sympy.Symbol('_Mathics_User_Global`y')) sym_expr = sympy.Derivative(sfxy, sympy.Symbol('_Mathics_User_Global`x')) self.compare_to_sympy(expr, sym_expr, **kwargs)
def testDerivative2(self): kwargs = {"converted_functions": set(["Global`f"])} head = mathics.Expression( mathics.Expression( "System`Derivative", mathics.Integer(1), mathics.Integer(0) ), mathics.Symbol("Global`f"), ) expr = mathics.Expression( head, mathics.Symbol("Global`x"), mathics.Symbol("Global`y") ) sfxy = sympy.Function(str("_Mathics_User_Global`f"))( sympy.Symbol("_Mathics_User_Global`x"), sympy.Symbol("_Mathics_User_Global`y"), ) sym_expr = sympy.Derivative(sfxy, sympy.Symbol("_Mathics_User_Global`x")) self.compare_to_sympy(expr, sym_expr, **kwargs)
def testComplex(self): self.compare(mathics.Complex(mathics.Integer(1), mathics.Integer(1)), 1 + 1j) self.compare( mathics.Complex(mathics.MachineReal(1.0), mathics.MachineReal(1.0)), 1.0 + 1.0j, ) self.compare( mathics.Complex(mathics.Integer(1), mathics.MachineReal(1.0)), 1 + 1.0j ) self.compare( mathics.Complex(mathics.MachineReal(1.0), mathics.Integer(1)), 1.0 + 1j ) self.compare( mathics.Complex(mathics.Real("1.0", 5), mathics.Integer(1)), 1.0 + 1j ) self.compare( mathics.Complex(mathics.Integer(1), mathics.Real("1.0", 20)), 1 + 1.0j ) self.compare(mathics.Complex(mathics.Integer(0), mathics.Integer(1)), 1j) self.compare(mathics.Complex(mathics.Integer(1), mathics.Integer(0)), 1)
def testInteger(self): self.compare(mathics.Integer(1), 1)
def testList(self): self.compare(mathics.Expression('List', mathics.Integer(1)), [1])
def testAdd(self): self.compare( mathics.Expression("Plus", mathics.Integer(1), mathics.Symbol("Global`x")), sympy.Add(sympy.Integer(1), sympy.Symbol("_Mathics_User_Global`x")), )