- self.assertEqual(self.x.subs('x', 3), 3)
- self.assertEqual(self.x.subs('x', self.x), self.x)
- self.assertEqual(self.x.subs('x', self.y), self.y)
- self.assertEqual(self.x.subs('x', self.x + self.y), self.x + self.y)
- self.assertEqual(self.x.subs('y', 3), self.x)
- self.assertEqual(self.pi.subs('x', 3), self.pi)
- self.assertEqual(self.expr.subs('x', -3), -2 * self.y)
- self.assertEqual(self.expr.subs([('x', self.y), ('y', self.x)]), 3 - self.x)
- self.assertEqual(self.expr.subs({'x': self.y, 'y': self.x}), 3 - self.x)
- self.assertEqual(self.expr.subs({self.x: self.y, self.y: self.x}), 3 - self.x)
+ self.assertEqual(self.x.subs(self.x, 3), 3)
+ self.assertEqual(self.x.subs(self.x, self.x), self.x)
+ self.assertEqual(self.x.subs(self.x, self.y), self.y)
+ self.assertEqual(self.x.subs(self.x, self.x + self.y), self.x + self.y)
+ self.assertEqual(self.x.subs(self.y, 3), self.x)
+ self.assertEqual(self.pi.subs(self.x, 3), self.pi)
+ self.assertEqual(self.expr.subs(self.x, -3), -2 * self.y)
+ self.assertEqual(self.expr.subs([(self.x, self.y), (self.y, self.x)]), 3 - self.x)
+ self.assertEqual(self.expr.subs({self.x: self.z, self.y: self.z}), 3 - self.z)
+ self.assertEqual(self.expr.subs({self.x: self.z, self.y: self.z}), 3 - self.z)
+ with self.assertRaises(TypeError):
+ self.x.subs('x', 3)
+ with self.assertRaises(TypeError):
+ self.expr.subs([('x', self.z), ('y', self.z)])
+ with self.assertRaises(TypeError):
+ self.expr.subs({'x': self.z, 'y': self.z})
+ with self.assertRaises(TypeError):
+ self.expr.subs(self.x, 'x')