From da198a0184bc373309a711b51d74527e08b595ae Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Wed, 17 Jan 2024 11:24:21 +0100
Subject: [PATCH] [py] ruff fixes in
 Tests/Data/Mechanics/Linear/PythonHertzContact.

---
 .../Mechanics/Linear/PythonHertzContact/gen-unit-circle.py   | 5 +++--
 .../Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py  | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Tests/Data/Mechanics/Linear/PythonHertzContact/gen-unit-circle.py b/Tests/Data/Mechanics/Linear/PythonHertzContact/gen-unit-circle.py
index df9a177feec..efe6cbb5344 100755
--- a/Tests/Data/Mechanics/Linear/PythonHertzContact/gen-unit-circle.py
+++ b/Tests/Data/Mechanics/Linear/PythonHertzContact/gen-unit-circle.py
@@ -1,6 +1,7 @@
 #!/usr/bin/vtkpython
 
 import sys
+from pathlib import Path
 
 import numpy as np
 import vtk
@@ -49,7 +50,7 @@ coords = vtk_to_numpy(grid.GetPoints().GetData())
 
 a = np.empty(coords.shape[0])
 
-for i, (x, y, z) in enumerate(coords):
+for i, (x, y, _z) in enumerate(coords):
     if x > y:
         R = np.sqrt(1 + (y / x) ** 2)
         a[i] = 1.0 / R
@@ -86,7 +87,7 @@ idcs = np.where(abs(R_squared - 1) < 1e-8)[0]
 idcs = idcs[np.argsort(phi[idcs])]  # sorted with ascending polar angle
 
 
-with open(out_geom, "w") as fh:
+with Path(out_geom).open(mode="w") as fh:
     fh.write(
         """<?xml version="1.0" encoding="ISO-8859-1"?>
 <OpenGeoSysGLI>
diff --git a/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py b/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py
index 36583ee1a82..517ca2ad441 100644
--- a/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py
+++ b/Tests/Data/Mechanics/Linear/PythonHertzContact/hertz_contact_bc.py
@@ -133,7 +133,7 @@ class HertzContactBC(OpenGeoSys.BoundaryCondition):
                 if x <= self._a_prev:
                     raise AssertionError()  # this case shouldn't happen
                     res = (True, y_top - y)
-                elif self._boundary_x_coords_are_initialized(t):
+                if self._boundary_x_coords_are_initialized(t):
                     idx = self._boundary_x_coords.index(x)
                     if idx != 0 and self._boundary_x_coords[idx - 1] == self._a_prev:
                         res = (True, y_top - y)
@@ -146,7 +146,7 @@ class HertzContactBC(OpenGeoSys.BoundaryCondition):
 
         return 1.0 - 0.005 * t
 
-    def _boundary_x_coords_are_initialized(self, t):
+    def _boundary_x_coords_are_initialized(self, _t):
         return self._iteration >= 2
 
 
-- 
GitLab