示例#1
0
 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)
示例#2
0
 def test_float(self):
     x = [0.5, -0.5, 1 / 8]
     self.assertEqual(linear.vecnorm(x), 5.15625e-1)
示例#3
0
 def test_pos(self):
     x = [1, 2, 3]
     self.assertEqual(linear.vecnorm(x), 14)
示例#4
0
 def test_neg(self):
     x = [-1, -2, -3]
     self.assertEqual(linear.vecnorm(x), 14)
示例#5
0
 def test_zero(self):
     zero_vec = [0 for _ in range(3)]
     self.assertEqual(linear.vecnorm(zero_vec), 0.0)