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