Code cleanup (PEP8)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 13 Nov 2018 19:43:09 +0000 (20:43 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 13 Nov 2018 19:43:09 +0000 (20:43 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP3/exo2/tp3_exo2.py

index 78392d9a193fcc9fbab2d0048a22bfd3d0daf6d2..2a831877d1afa81b9794af3a9cc89541789eb242 100755 (executable)
@@ -87,7 +87,8 @@ def complete(sample):
 
 
 def plongement_phi(sample_element):
-    return [1, sample_element[0], sample_element[1], sample_element[0] * sample_element[0], sample_element[0] * sample_element[1], sample_element[1] * sample_element[1]]
+    return [1, sample_element[0], sample_element[1], sample_element[0]**2,
+            sample_element[0] * sample_element[1], sample_element[1]**2]
 
 
 def apply_plongement(sample, p):
@@ -106,7 +107,8 @@ def f_from_k(coeffs, support_set, k, x):
 
 
 def k1(X1, X2):
-    return 1 + X1[0] * X2[0] + X1[1] * X2[1] + X1[0] * X1[0] * X2[0] * X2[0] + X1[0] * X1[1] * X2[0] * X2[1] + X1[1] * X1[1] * X2[1] * X2[1]
+    return 1 + X1[0] * X2[0] + X1[1] * X2[1] + X1[0]**2 * X2[0]**2 \
+             + X1[0] * X1[1] * X2[0] * X2[1] + X1[1]**2 * X2[1]**2
 
 
 def kg(x, y, sigma=10):