diff --git a/ogstools/meshlib/mesh_series.py b/ogstools/meshlib/mesh_series.py
index 11b3d629338bc7c03a81bb53c7dcdc53157b7a28..2a96a9bbf1bab83ae7d4a83272a9001b8a934ce3 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 0c104be98cfb42d2c40f8c3e4b6a10c609007cdf..f064a72e2d56efc439c0d989229cf8c05bd1a1af 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