def test_ast_getterms(self): n = ast.parse('x+y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['x'], ['y']]) n = ast.parse('x-y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['x'], [-1, 'y']]) n = ast.parse('3*x-y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [[3, 'x'], [-1, 'y']])
def test_multiproducts(self): n = ast.parse('a*x+a*b*c*y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['a', 'x'], ['a', 'b', 'c', 'y']]) n = ast.parse('-a*x+a*b*c*y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [[-1, 'a', 'x'], ['a', 'b', 'c', 'y']]) n = ast.parse('a*x-a*b*c*y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['a', 'x'], [-1, 'a', 'b', 'c', 'y']])
def test_ast_getterms(self): n = ast.parse('x+y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['x'],['y']]) n = ast.parse('x-y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['x'],[-1,'y']]) n = ast.parse('3*x-y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [[3,'x'],[-1,'y']])
def test_multiproducts(self): n = ast.parse('a*x+a*b*c*y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['a','x'],['a','b','c','y']]) n = ast.parse('-a*x+a*b*c*y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [[-1,'a','x'],['a','b','c','y']]) n = ast.parse('a*x-a*b*c*y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [['a','x'],[-1,'a','b','c','y']])
def test_unary(self): n = ast.parse('-x+y', mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [[-1, 'x'], ['y']])
def test_unary(self): n = ast.parse('-x+y',mode='eval') terms = linsolve.ast_getterms(n) self.assertEqual(terms, [[-1,'x'],['y']])