From 0d9acf30d2e005d703efe8324eddcff40d4c0874 Mon Sep 17 00:00:00 2001 From: Sven Marcus <s.marcus@outlook.de> Date: Wed, 7 Oct 2020 10:49:13 +0200 Subject: [PATCH] Adds test description, some formatting --- Python/norms.py | 11 +++++------ Python/test_geometry.py | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Python/norms.py b/Python/norms.py index 4280c4981..40018ac01 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 c2558cb1c..5e953f58b 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() -- GitLab