From c1ca25811c3a47fdc5583918a86753f05049ef0f Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Wed, 17 Jan 2024 12:00:05 +0100
Subject: [PATCH] [py] ruff fixes in Tests/Data/HydroMechanics.

---
 .../flow_pressure_boundary/python_boundary.py       |  4 ++--
 .../Unconfined_Compression_early/python_boundary.py |  6 +++---
 .../SeabedResponse/Stationary_waves.ipynb           | 13 +++++++------
 .../InjectionProduction1D/python_boundary.py        | 10 ++++------
 .../python_boundary_staggered.py                    |  8 ++++----
 5 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/Tests/Data/HydroMechanics/IdealGas/flow_pressure_boundary/python_boundary.py b/Tests/Data/HydroMechanics/IdealGas/flow_pressure_boundary/python_boundary.py
index 7889b8fd670..3dc14a7d486 100644
--- a/Tests/Data/HydroMechanics/IdealGas/flow_pressure_boundary/python_boundary.py
+++ b/Tests/Data/HydroMechanics/IdealGas/flow_pressure_boundary/python_boundary.py
@@ -10,12 +10,12 @@ p_0 = 1e5
 # Source Terms
 ## Pressure
 class BC_p_D(OpenGeoSys.BoundaryCondition):
-    def getDirichletBCValue(self, t, coords, node_id, primary_vars):
+    def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
         return (True, p_0)
 
 
 class BC_p_N(OpenGeoSys.BoundaryCondition):
-    def getFlux(self, t, coords, primary_vars):
+    def getFlux(self, _t, _coords, _primary_vars):
         Jac = [0.0, 0.0, 0.0]
         return (True, p_flux_in, Jac)
 
diff --git a/Tests/Data/HydroMechanics/Linear/Unconfined_Compression_early/python_boundary.py b/Tests/Data/HydroMechanics/Linear/Unconfined_Compression_early/python_boundary.py
index b676a7a79df..4598844cf8e 100644
--- a/Tests/Data/HydroMechanics/Linear/Unconfined_Compression_early/python_boundary.py
+++ b/Tests/Data/HydroMechanics/Linear/Unconfined_Compression_early/python_boundary.py
@@ -11,19 +11,19 @@ dirichlet_pressure_0 = 0
 # Boundary conditions
 ## Pressure
 class BC_p_D_0(OpenGeoSys.BoundaryCondition):
-    def getDirichletBCValue(self, t, coords, node_id, primary_vars):
+    def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
         return (True, dirichlet_pressure_0)
 
 
 ## Displacement
 ### Dirichlet
 class BC_u_D_0(OpenGeoSys.BoundaryCondition):
-    def getDirichletBCValue(self, t, coords, node_id, primary_vars):
+    def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
         return (True, dirichlet_displacement_0)
 
 
 class BC_u_D_top(OpenGeoSys.BoundaryCondition):
-    def getDirichletBCValue(self, t, coords, node_id, primary_vars):
+    def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
         return (True, dirichlet_displacement_top)
 
 
diff --git a/Tests/Data/HydroMechanics/SeabedResponse/Stationary_waves.ipynb b/Tests/Data/HydroMechanics/SeabedResponse/Stationary_waves.ipynb
index 0c4dfe199c8..500d30a44b4 100644
--- a/Tests/Data/HydroMechanics/SeabedResponse/Stationary_waves.ipynb
+++ b/Tests/Data/HydroMechanics/SeabedResponse/Stationary_waves.ipynb
@@ -533,10 +533,11 @@
    "outputs": [],
    "source": [
     "import os\n",
+    "from pathlib import Path\n",
     "\n",
-    "# out_dir will contain all data we produce\n",
-    "out_dir = os.environ.get(\"OGS_TESTRUNNER_OUT_DIR\", \"_out\")\n",
-    "os.makedirs(out_dir, exist_ok=True)"
+    "out_dir = Path(os.environ.get(\"OGS_TESTRUNNER_OUT_DIR\", \"_out\"))\n",
+    "if not out_dir.exists():\n",
+    "    out_dir.mkdir(parents=True)"
    ]
   },
   {
@@ -742,7 +743,7 @@
    ],
    "source": [
     "!msh2vtu --ogs {input_file}\n",
-    "assert _exit_code == 0"
+    "assert _exit_code == 0  # noqa: F821"
    ]
   },
   {
@@ -927,7 +928,7 @@
     "    return f_abs, f_rel\n",
     "\n",
     "\n",
-    "def compute_abs_and_rel_stress_error(sigmas, depth, t, x):\n",
+    "def compute_abs_and_rel_stress_error(_sigmas, depth, t, x):\n",
     "    num_points = depth.shape[0]\n",
     "    f_abs = np.zeros((3, num_points))\n",
     "    f_rel = np.zeros((3, num_points))\n",
@@ -1012,7 +1013,7 @@
     "\n",
     "plotter = pv.Plotter()\n",
     "\n",
-    "sargs = dict(title=\"p / Pa\", height=0.25, position_x=0.2, position_y=0.02)\n",
+    "sargs = dict(title=\"p / Pa\", height=0.25, position_x=0.2, position_y=0.02)  # noqa: C408\n",
     "plotter.add_mesh(\n",
     "    mesh,\n",
     "    scalars=\"pressure_interpolated\",\n",
diff --git a/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary.py b/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary.py
index 703478d3f35..335b1b1ad01 100644
--- a/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary.py
+++ b/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary.py
@@ -12,15 +12,13 @@ source_term_production = -1.16e-4
 # Source Terms
 ## Pressure
 class Source_p_injection(OpenGeoSys.SourceTerm):
-    def getFlux(self, t, coords, primary_vars):
-        # print("ST prim vars:", primary_vars)
+    def getFlux(self, _t, _coords, _primary_vars):
         Jac = [0.0, 0.0, 0.0]
         return (source_term_injection, Jac)
 
 
 class Source_p_production(OpenGeoSys.SourceTerm):
-    def getFlux(self, t, coords, primary_vars):
-        # print("ST prim vars:", primary_vars)
+    def getFlux(self, _t, _coords, _primary_vars):
         Jac = [0.0, 0.0, 0.0]
         return (source_term_production, Jac)
 
@@ -32,13 +30,13 @@ class Source_p_production(OpenGeoSys.SourceTerm):
 ## Displacement
 ### Dirichlet
 class BC_u_D(OpenGeoSys.BoundaryCondition):
-    def getDirichletBCValue(self, t, coords, node_id, primary_vars):
+    def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
         # print(f"DBC xs={coords} pvs={primary_vars}")
         return (True, dirichlet_displacement_0)
 
 
 class BC_u_N(OpenGeoSys.BoundaryCondition):
-    def getFlux(self, t, coords, primary_vars):
+    def getFlux(self, _t, _coords, _primary_vars):
         # print(f"NBC xs={coords} pvs={primary_vars}")
         Jac = [0.0, 0.0, 0.0]
         return (True, neumann_displacement_overburden, Jac)
diff --git a/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary_staggered.py b/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary_staggered.py
index bc9f209eeb8..a91a46222ff 100644
--- a/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary_staggered.py
+++ b/Tests/Data/HydroMechanics/StaggeredScheme/InjectionProduction1D/python_boundary_staggered.py
@@ -12,13 +12,13 @@ source_term_production = -1.16e-4
 # Source Terms
 ## Pressure
 class Source_p_injection(OpenGeoSys.SourceTerm):
-    def getFlux(self, t, coords, primary_vars):
+    def getFlux(self, _t, _coords, _primary_vars):
         Jac = [0.0]
         return (source_term_injection, Jac)
 
 
 class Source_p_production(OpenGeoSys.SourceTerm):
-    def getFlux(self, t, coords, primary_vars):
+    def getFlux(self, _t, _coords, _primary_vars):
         Jac = [0.0]
         return (source_term_production, Jac)
 
@@ -30,12 +30,12 @@ class Source_p_production(OpenGeoSys.SourceTerm):
 ## Displacement
 ### Dirichlet
 class BC_u_D(OpenGeoSys.BoundaryCondition):
-    def getDirichletBCValue(self, t, coords, node_id, primary_vars):
+    def getDirichletBCValue(self, _t, _coords, _node_id, _primary_vars):
         return (True, dirichlet_displacement_0)
 
 
 class BC_u_N(OpenGeoSys.BoundaryCondition):
-    def getFlux(self, t, coords, primary_vars):
+    def getFlux(self, _t, _coords, _primary_vars):
         Jac = [0.0, 0.0]
         return (True, neumann_displacement_overburden, Jac)
 
-- 
GitLab