diff --git a/Python/norms.py b/Python/norms.py index 4280c49818e1234f9fb437b52b025956ab252c4a..40018ac018f4651339c9783d8b1b22e4c9612c52 100644 --- a/Python/norms.py +++ b/Python/norms.py @@ -7,9 +7,8 @@ def l2_norm(real_values, numerical_values): raise ValueError("Real and numerical value lists must be same length") combined_values = zip(real_values, numerical_values) - return math.sqrt( - 1 / num_values - * sum( - (real_value - numerical_value) ** 2 - for real_value, numerical_value in combined_values - )) + sum_of_squared_distances = sum((real_value - numerical_value) ** 2 + for real_value, numerical_value + in combined_values) + + return math.sqrt(1 / num_values * sum_of_squared_distances) diff --git a/Python/test_geometry.py b/Python/test_geometry.py index c2558cb1c804db31a70a470079d6bc64538b5a75..5e953f58b4b24393ae3a8f2994184c9c7f27eca3 100644 --- a/Python/test_geometry.py +++ b/Python/test_geometry.py @@ -30,6 +30,9 @@ class TestGeometry(unittest.TestCase): self.assertEqual(sut.x3, 3) def test_when_setting_line_points__line_should_have_points(self): + """ + WHEN setting line points THEN line should have points + """ sut = GbLine3D() point1 = GbPoint3D()