Beispiel #1
0
    def test_step(self):
        """gradient -- step"""
        v = [random.randint(-10, 10) for i in range(3)]

        tolerance = 0.0000001
        while True:
            _gradient = gradient.sum_of_squares_gradient(v)
            next_v = gradient.step(v, _gradient, -0.01)
            if algebra.distance(next_v, v) < tolerance:
                break
            v = next_v

        expected = [0.0, 0.0, 0.0]
        returned = map(lambda x: round(x, 5), v)
        self.assertEqual(returned, expected)
Beispiel #2
0
 def test_distance(self):
     """algebra -- distance"""
     dist = algebra.distance(self.a, self.b)
     self.assertEqual(10.77, round(dist, 2))
Beispiel #3
0
 def test_distance(self):
     """algebra -- distance"""
     dist = algebra.distance(self.a, self.b)
     self.assertEqual(10.77, round(dist, 2))