From f61a059d71f7c79ee9ac62a85ab24dd9c22745b9 Mon Sep 17 00:00:00 2001
From: joergbuchwald <joerg.buchwald@ufz.de>
Date: Thu, 23 Jan 2025 12:32:00 +0000
Subject: [PATCH] rename i -> tv as animate only accepts timevalues as
 arguments

---
 ogstools/meshlib/mesh_series.py |  6 +++---
 tests/test_meshlib.py           | 16 ++++------------
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/ogstools/meshlib/mesh_series.py b/ogstools/meshlib/mesh_series.py
index 11b3d6293..2a96a9bbf 100644
--- a/ogstools/meshlib/mesh_series.py
+++ b/ogstools/meshlib/mesh_series.py
@@ -619,14 +619,14 @@ class MeshSeries:
         def init() -> None:
             pass
 
-        def animate_func(i: int | float, fig: plt.Figure) -> None:
+        def animate_func(tv: float, fig: plt.Figure) -> None:
             fig.axes[-1].remove()  # remove colorbar
             for ax in np.ravel(np.asarray(fig.axes)):
                 ax.clear()
-            mesh = self[i] if isinstance(i, int) else self.read_interp(i, True)
+            mesh = self.read_interp(tv, True)
             with warnings.catch_warnings():
                 warnings.simplefilter("ignore")
-                plot_func(fig.axes[0], i)
+                plot_func(fig.axes[0], tv)
                 plot.contourplots.draw_plot(
                     mesh, variable, fig=fig, axes=fig.axes[0], **kwargs
                 )  # type: ignore[assignment]
diff --git a/tests/test_meshlib.py b/tests/test_meshlib.py
index 0c104be98..f064a72e2 100644
--- a/tests/test_meshlib.py
+++ b/tests/test_meshlib.py
@@ -499,12 +499,8 @@ class TestUtils:
         pvd_entries = tree.findall("./Collection/DataSet")
         for i in range(num_slices):
             assert ms[i].filepath.name == pvd_entries[i].attrib["file"]
-            assert (
-                np.abs(
-                    ms.timevalues[i] - float(pvd_entries[i].attrib["timestep"])
-                )
-                < 1e-14
-            )
+            ts = float(pvd_entries[i].attrib["timestep"])
+            assert np.abs(ms.timevalues[i] - ts) < 1e-14
 
     def test_save_xdmf_mesh_series(self):
         temp = Path(mkdtemp())
@@ -532,9 +528,5 @@ class TestUtils:
         num_slices_test = len(pvd_entries)
         assert num_slices == num_slices_test
         for i in range(num_slices):
-            assert (
-                np.abs(
-                    ms.timevalues[i] - float(pvd_entries[i].attrib["timestep"])
-                )
-                < 1e-14
-            )
+            ts = float(pvd_entries[i].attrib["timestep"])
+            assert np.abs(ms.timevalues[i] - ts) < 1e-14
-- 
GitLab