From 4be43528e30ebd5bff20dc2262c3752d2b79e12d Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Wed, 15 May 2024 11:29:39 +0200
Subject: [PATCH] Pamhyr: Fix Pep8.

---
 src/Meshing/Mage.py                  |  4 ++--
 src/Model/Geometry/ProfileXYZ.py     | 35 +++++++++++++++++++++-------
 src/View/Geometry/UpdateKPDialog.py  |  6 +++--
 src/View/InitialConditions/Window.py |  4 ++--
 src/View/Results/PlotKPC.py          |  8 +++----
 src/View/Tools/Plot/PamhyrToolbar.py |  1 -
 6 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/src/Meshing/Mage.py b/src/Meshing/Mage.py
index 90f44d56..1e8f4c2d 100644
--- a/src/Meshing/Mage.py
+++ b/src/Meshing/Mage.py
@@ -298,7 +298,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
                 lplan: bool = False,
                 lm: int = 3,
                 linear: bool = False,
-                origin_value = 0.0):
+                origin_value=0.0):
         if reach is None or len(reach.profiles) == 0:
             return reach
 
@@ -371,7 +371,7 @@ class MeshingWithMageMailleurTT(AMeshingTool):
                   lplan: bool = False,
                   lm: int = 3,
                   linear: bool = False,
-                  origin_value = 0.0):
+                  origin_value=0.0):
         if reach is None or len(reach.profiles) == 0:
             return reach
 
diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py
index 0bd8d83d..ff5ae599 100644
--- a/src/Model/Geometry/ProfileXYZ.py
+++ b/src/Model/Geometry/ProfileXYZ.py
@@ -583,27 +583,44 @@ class ProfileXYZ(Profile, SQLSubModel):
         """
         Remove points to keep at most np_purge points.
         """
+        if (self.nb_points <= np_purge):
+            return
 
-        if (self.nb_points <= np_purge): return
-
-        nb_named = 2 # we consider the first and last point as named
+        nb_named = 2   # we consider the first and last point as named
         area = [0.0]
+
         for i in range(1, self.nb_points-1):
             if self.point(i).point_is_named():
                 area.append(9999999.999)
                 nb_named += 1
             else:
-                area.append(PointXYZ.areatriangle3d(self.point(i-1),self.point(i),self.point(i+1)))
+                area.append(
+                    PointXYZ.areatriangle3d(
+                        self.point(i-1),
+                        self.point(i),
+                        self.point(i+1))
+                )
+
         area.append(0.0)
 
-        while (self.nb_points > max(np_purge, nb_named)):
-            to_rm = np.argmin(area[1:self.nb_points-1])+1
+        while self.nb_points > max(np_purge, nb_named):
+            to_rm = np.argmin(area[1:self.nb_points - 1]) + 1
+
             self.delete_i([to_rm])
             area.pop(to_rm)
+
             for i in [to_rm-1, to_rm]:
-                if (i == 0): continue
-                if (i == self.nb_points - 1): continue
+                if (i == 0):
+                    continue
+
+                if (i == self.nb_points - 1):
+                    continue
+
                 if self.point(i).point_is_named():
                     area[i] = 9999999.999
                 else:
-                    area[i] = PointXYZ.areatriangle3d(self.point(i-1),self.point(i),self.point(i+1))
+                    area[i] = PointXYZ.areatriangle3d(
+                        self.point(i-1),
+                        self.point(i),
+                        self.point(i+1)
+                    )
diff --git a/src/View/Geometry/UpdateKPDialog.py b/src/View/Geometry/UpdateKPDialog.py
index 08abf1f4..87afc977 100644
--- a/src/View/Geometry/UpdateKPDialog.py
+++ b/src/View/Geometry/UpdateKPDialog.py
@@ -74,8 +74,10 @@ class UpdateKPDialog(PamhyrDialog):
 
     def changed_profile(self):
         origin = self.get_combobox_text("comboBox_origin")
-        self.set_double_spin_box("doubleSpinBox_origin",
-                                 self._reach.profile(self.profiles.index(origin)).kp)
+        self.set_double_spin_box(
+            "doubleSpinBox_origin",
+            self._reach.profile(self.profiles.index(origin)).kp
+        )
 
     @property
     def profiles(self):
diff --git a/src/View/InitialConditions/Window.py b/src/View/InitialConditions/Window.py
index 5dfb4cfa..82946e84 100644
--- a/src/View/InitialConditions/Window.py
+++ b/src/View/InitialConditions/Window.py
@@ -170,7 +170,8 @@ class InitialConditionsWindow(PamhyrWindow):
         self.find(QAction, "action_add").triggered.connect(self.add)
         self.find(QAction, "action_del").triggered.connect(self.delete)
         self.find(QAction, "action_sort").triggered.connect(self.sort)
-        self.find(QAction, "action_import").triggered.connect(self.import_from_file)
+        self.find(QAction, "action_import").triggered\
+                                           .connect(self.import_from_file)
 
         self.find(QPushButton, "pushButton_generate_1").clicked.connect(
             self.generate_growing_constante_height
@@ -192,7 +193,6 @@ class InitialConditionsWindow(PamhyrWindow):
 
         return rows[0].row()
 
-
     def update(self):
         self._update_plot()
         self._propagate_update(key=Modules.INITIAL_CONDITION)
diff --git a/src/View/Results/PlotKPC.py b/src/View/Results/PlotKPC.py
index d6f5feae..01bf7a6a 100644
--- a/src/View/Results/PlotKPC.py
+++ b/src/View/Results/PlotKPC.py
@@ -115,8 +115,8 @@ class PlotKPC(PamhyrPlot):
                     lambda z, h: z - h[0],
                     sl, z
                 ),
-                z_min,          #  Original geometry
-                sl              #  Original sediment layers
+                z_min,          # Original geometry
+                sl              # Original sediment layers
             )
         )
 
@@ -132,8 +132,8 @@ class PlotKPC(PamhyrPlot):
                     lambda z, h: z + h[0],
                     sl, z
                 ),
-                z_br,           #  Bedrock elevation
-                sl              #  Current sediment layers
+                z_br,           # Bedrock elevation
+                sl              # Current sediment layers
             )
         )
 
diff --git a/src/View/Tools/Plot/PamhyrToolbar.py b/src/View/Tools/Plot/PamhyrToolbar.py
index 0d060ec4..2a851c92 100644
--- a/src/View/Tools/Plot/PamhyrToolbar.py
+++ b/src/View/Tools/Plot/PamhyrToolbar.py
@@ -200,7 +200,6 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
 
         self.icons.append(("save_figure", icon_save))
 
-
     def save_figure(self, *args):
         file_types = self.canvas.get_supported_filetypes_grouped()
         default_file_type = self.canvas.get_default_filetype()
-- 
GitLab