示例#1
0
文件: test.py 项目: erictchin/cs4500
 def test_zeros(self):
   """Tests that the distance between the origin and itself is 0."""
   self.assertEqual(comparator.euclidean_distance(self.two_zeros,
                                                  self.two_zeros),
                    0)
   self.assertEqual(comparator.euclidean_distance(self.five_zeros,
                                                  self.five_zeros),
                    0)
示例#2
0
文件: test.py 项目: erictchin/cs4500
 def test_hypotenuse_is_five(self):
   """Tests that the distance between (0, 0) and (3, 4) is 5."""
   self.assertEqual(comparator.euclidean_distance(self.two_zeros,
                                                  self.three_four),
                    5)
   self.assertEqual(comparator.euclidean_distance(self.three_four,
                                                  self.two_zeros),
                    5)
   self.assertEqual(comparator.euclidean_distance(self.two_zeros,
                                                  self.complex_three_four),
                    5)
   self.assertEqual(comparator.euclidean_distance(self.complex_three_four,
                                                  self.two_zeros),
                    5)
示例#3
0
文件: test.py 项目: erictchin/cs4500
 def test_distance_ones_to_ones(self):
   """Tests that the distance between any vector and an equivalent
   vector is 0."""
   self.assertEqual(comparator.euclidean_distance(self.int_ones,
                                                  self.int_ones),
                    0)
   self.assertEqual(comparator.euclidean_distance(self.complex_ones,
                                                  self.complex_ones),
                    0)
   self.assertEqual(comparator.euclidean_distance(self.int_ones,
                                                  self.complex_ones),
                    0)
   self.assertEqual(comparator.euclidean_distance(self.complex_ones,
                                                  self.int_ones),
                    0)
示例#4
0
文件: test.py 项目: erictchin/cs4500
 def test_hypotenuse_is_sqrt_five(self):
   """Tests that the distance between (0, 0, 0, 0, 0) and
   (1, 1, 1, 1, 1) is sqrt(5)."""
   self.assertEqual(comparator.euclidean_distance(self.five_zeros,
                                                  self.int_ones),
                    math.sqrt(5))