self.pi = constant(Fraction(22, 7))
self.e = self.x - 2*self.y + 3
self.pi = constant(Fraction(22, 7))
self.e = self.x - 2*self.y + 3
self.assertCountEqual(self.x.symbols(), ['x'])
self.assertCountEqual(self.pi.symbols(), [])
self.assertCountEqual(self.e.symbols(), ['x', 'y'])
self.assertCountEqual(self.x.symbols(), ['x'])
self.assertCountEqual(self.pi.symbols(), [])
self.assertCountEqual(self.e.symbols(), ['x', 'y'])
def test_dimension(self):
self.assertEqual(self.x.dimension, 1)
def test_dimension(self):
self.assertEqual(self.x.dimension, 1)
self.assertEqual(self.e.coefficient('x'), 1)
self.assertEqual(self.e.coefficient('y'), -2)
self.assertEqual(self.e.coefficient(self.y), -2)
self.assertEqual(self.e.coefficient('x'), 1)
self.assertEqual(self.e.coefficient('y'), -2)
self.assertEqual(self.e.coefficient(self.y), -2)
self.assertEqual(self.e['x'], 1)
self.assertEqual(self.e['y'], -2)
self.assertEqual(self.e[self.y], -2)
self.assertEqual(self.e['x'], 1)
self.assertEqual(self.e['y'], -2)
self.assertEqual(self.e[self.y], -2)
self.assertCountEqual(self.e.coefficients(), [('x', 1), ('y', -2)])
def test_constant(self):
self.assertCountEqual(self.e.coefficients(), [('x', 1), ('y', -2)])
def test_constant(self):
self.assertEqual(self.pi.constant, Fraction(22, 7))
self.assertEqual(self.e.constant, 3)
self.assertEqual(self.pi.constant, Fraction(22, 7))
self.assertEqual(self.e.constant, 3)
def test_sub(self):
self.assertEqual(self.x - self.x, 0)
self.assertEqual(self.e - 3, self.x - 2*self.y)
def test_sub(self):
self.assertEqual(self.x - self.x, 0)
self.assertEqual(self.e - 3, self.x - 2*self.y)
self.assertEqual(str(self.x), 'x')
self.assertEqual(str(-self.x), '-x')
self.assertEqual(str(self.pi), '22/7')
self.assertEqual(str(self.x), 'x')
self.assertEqual(str(-self.x), '-x')
self.assertEqual(str(self.pi), '22/7')
self.assertEqual(symbol('x'), self.x)
self.assertNotEqual(symbol('y'), self.x)
with self.assertRaises(TypeError):
self.assertEqual(symbol('x'), self.x)
self.assertNotEqual(symbol('y'), self.x)
with self.assertRaises(TypeError):