From c26e1f7e37e379f0c0d94b2572e941833e47b9cc Mon Sep 17 00:00:00 2001
From: David Bold <dave@ipp.mpg.de>
Date: Wed, 5 Jul 2023 11:21:44 +0200
Subject: [PATCH 1/3] Update method for clearing ax.collections
---
animatplot/blocks/surface.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/animatplot/blocks/surface.py b/animatplot/blocks/surface.py
index 20de5ad..729e58f 100644
--- a/animatplot/blocks/surface.py
+++ b/animatplot/blocks/surface.py
@@ -69,7 +69,9 @@ def __init__(self, *args, ax=None, t_axis=0, fixed_vscale=True, **kwargs):
def _update(self, i):
Slice = self._make_slice(i, 3)
- self.ax.collections.clear()
+ # https://stackoverflow.com/a/43081720 also recommends iterating over self.ax.lines
+ for artist in self.ax.collections:
+ artist.remove()
self.poly = self.ax.plot_surface(self.X, self.Y, self.C[Slice], **self.kwargs)
return self.poly
From 58a260dd4390ca174c26f1622a2bbdb053f8be2d Mon Sep 17 00:00:00 2001
From: David Bold <dave@ipp.mpg.de>
Date: Wed, 5 Jul 2023 11:22:32 +0200
Subject: [PATCH 2/3] Do not test ragged arrays
They are mostly disabled in numpy, thus assuming they
are not passed to animatplot
---
tests/test_blocks.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/test_blocks.py b/tests/test_blocks.py
index d3ac4fe..9e16e78 100644
--- a/tests/test_blocks.py
+++ b/tests/test_blocks.py
@@ -141,6 +141,9 @@ def test_list_input(self):
npt.assert_equal(line_block.x, np.array([[1, 2, 3], [1, 2, 3]]))
def test_ragged_list_input(self):
+ npv = tuple([int(x) for x in np.__version__.split(".")[:3]])
+ if npv >= (1, 24):
+ pytest.skip("numpy to new - will raise error")
x_data = [np.array([1, 2, 3]), np.array([1, 2, 3, 4])]
y_data = [np.array([5, 6, 7]), np.array([4, 2, 9, 10])]
@@ -154,6 +157,9 @@ def test_ragged_list_input(self):
assert_jagged_arrays_equal(line_block.y, np.array(y_data))
def test_bad_ragged_list_input(self):
+ npv = tuple([int(x) for x in np.__version__.split(".")[:3]])
+ if npv >= (1, 24):
+ pytest.skip("numpy to new - will raise error")
x_data = np.array([np.array([1, 2, 3]), np.array([1, 2, 3, 4])])
y_data = np.array([np.array([5, 6, 7]), np.array([4, 2, 9, 10, 11])])
From b493696bacb041dd4c35ce5a19dec9ee994f76d3 Mon Sep 17 00:00:00 2001
From: dschwoerer <dschwoerer@users.noreply.github.com>
Date: Wed, 5 Jul 2023 09:24:15 +0000
Subject: [PATCH 3/3] Apply black changes
---
animatplot/blocks/lineplots.py | 1 -
animatplot/blocks/title.py | 1 -
tests/tools.py | 1 -
3 files changed, 3 deletions(-)
diff --git a/animatplot/blocks/lineplots.py b/animatplot/blocks/lineplots.py
index 633f41a..651c5ee 100644
--- a/animatplot/blocks/lineplots.py
+++ b/animatplot/blocks/lineplots.py
@@ -44,7 +44,6 @@ class Line(Block):
"""
def __init__(self, *args, ax=None, t_axis=0, **kwargs):
-
super().__init__(ax, t_axis)
if len(args) == 1:
diff --git a/animatplot/blocks/title.py b/animatplot/blocks/title.py
index 712250b..57f7cbb 100644
--- a/animatplot/blocks/title.py
+++ b/animatplot/blocks/title.py
@@ -38,7 +38,6 @@ def __init__(self, text, ax=None, *args, **kwargs):
super().__init__(ax)
if isinstance(text, str):
-
# Filter out only the keyword args which are things to be replaced
# in the title text
# Parsing trick from https://stackoverflow.com/questions/25996937/
diff --git a/tests/tools.py b/tests/tools.py
index 353cc8e..d1f2c68 100644
--- a/tests/tools.py
+++ b/tests/tools.py
@@ -66,7 +66,6 @@ def animation_compare(baseline_images, nframes, fmt=".png", tol=1e-3, remove_tex
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
-
# First close anything from previous tests
plt.close("all")