def test_string(self): x = ['a', 'b', 'c'] # Note: self.assertWarns is also useful to test for e.g. divide by # zero errors with self.assertRaises(TypeError): linear.vecnorm(x)
def test_float(self): x = [0.5, -0.5, 1 / 8] self.assertEqual(linear.vecnorm(x), 5.15625e-1)
def test_pos(self): x = [1, 2, 3] self.assertEqual(linear.vecnorm(x), 14)
def test_neg(self): x = [-1, -2, -3] self.assertEqual(linear.vecnorm(x), 14)
def test_zero(self): zero_vec = [0 for _ in range(3)] self.assertEqual(linear.vecnorm(zero_vec), 0.0)