Exemple #1
0
 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']])
Exemple #2
0
 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']])
Exemple #3
0
 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']])
Exemple #4
0
 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']])
Exemple #5
0
 def test_unary(self):
     n = ast.parse('-x+y', mode='eval')
     terms = linsolve.ast_getterms(n)
     self.assertEqual(terms, [[-1, 'x'], ['y']])
Exemple #6
0
 def test_unary(self):
     n = ast.parse('-x+y',mode='eval')
     terms = linsolve.ast_getterms(n)
     self.assertEqual(terms, [[-1,'x'],['y']])