Skip to content

Commit 411ea35

Browse files
committed
Expire remaining features deprecated in mpl2.2.
1 parent 52485ff commit 411ea35

File tree

4 files changed

+22
-35
lines changed

4 files changed

+22
-35
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,17 @@ property. This now raises a TypeError.
6262
`.FileMovieWriter` now defaults to writing temporary frames in a temporary
6363
directory, which is always cleared at exit. In order to keep the individual
6464
frames saved on the filesystem, pass an explicit *frame_prefix*.
65+
66+
Animations whose len() cannot be determined are no longer truncated to 100 frames when saved
67+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68+
Instead, the underlying iterable will be consumed until it terminates. Beware:
69+
attempting to save an animation whose underlying iterable is infinite will lead
70+
to an infinite loop!
71+
72+
`.Axes.plot` no longer accepts *x* and *y* being both 2D and with different numbers of columns
73+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74+
Previously, calling `.Axes.plot` e.g. with *x* of shape ``(n, 3)`` and *y* of
75+
shape ``(n, 2)`` would plot the first column of *x* against the first column
76+
of *y*, the second column of *x* against the second column of *y*, **and** the
77+
first column of *x* against the third column of *y*. This now raises an error
78+
instead.

lib/matplotlib/animation.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,10 +1666,7 @@ def iter_frames(frames=frames):
16661666
self._iter_gen = lambda: iter(range(frames))
16671667
self.save_count = frames
16681668

1669-
if self.save_count is None:
1670-
# If we're passed in and using the default, set save_count to 100.
1671-
self.save_count = 100
1672-
else:
1669+
if self.save_count is not None:
16731670
# itertools.islice returns an error when passed a numpy int instead
16741671
# of a native python int (http://bugs.python.org/issue30537).
16751672
# As a workaround, convert save_count to a native python int.
@@ -1700,26 +1697,7 @@ def new_saved_frame_seq(self):
17001697
self._old_saved_seq = list(self._save_seq)
17011698
return iter(self._old_saved_seq)
17021699
else:
1703-
if self.save_count is not None:
1704-
return itertools.islice(self.new_frame_seq(), self.save_count)
1705-
1706-
else:
1707-
frame_seq = self.new_frame_seq()
1708-
1709-
def gen():
1710-
try:
1711-
for _ in range(100):
1712-
yield next(frame_seq)
1713-
except StopIteration:
1714-
pass
1715-
else:
1716-
cbook.warn_deprecated(
1717-
"2.2", message="FuncAnimation.save has truncated "
1718-
"your animation to 100 frames. In the future, no "
1719-
"such truncation will occur; please pass "
1720-
"'save_count' accordingly.")
1721-
1722-
return gen()
1700+
return itertools.islice(self.new_frame_seq(), self.save_count)
17231701

17241702
def _init_draw(self):
17251703
# Initialize the drawing either using the given init_func or by
@@ -1746,7 +1724,8 @@ def _draw_frame(self, framedata):
17461724

17471725
# Make sure to respect save_count (keep only the last save_count
17481726
# around)
1749-
self._save_seq = self._save_seq[-self.save_count:]
1727+
if self.save_count is not None:
1728+
self._save_seq = self._save_seq[-self.save_count:]
17501729

17511730
# Call the func with framedata and args. If blitting is desired,
17521731
# func needs to return a sequence of any artists that were modified.

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ def _plot_args(self, tup, kwargs):
356356

357357
ncx, ncy = x.shape[1], y.shape[1]
358358
if ncx > 1 and ncy > 1 and ncx != ncy:
359-
cbook.warn_deprecated(
360-
"2.2", message="cycling among columns of inputs with "
361-
"non-matching shapes is deprecated.")
359+
raise ValueError(f"x has {ncx} columns but y has {ncy} columns")
362360
return [func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
363361
for j in range(max(ncx, ncy))]
364362

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,12 +5479,13 @@ def test_square_plot():
54795479
ax.get_position(original=False).extents, (0.2125, 0.1, 0.8125, 0.9))
54805480

54815481

5482-
def test_no_None():
5483-
fig, ax = plt.subplots()
5482+
def test_bad_plot_args():
54845483
with pytest.raises(ValueError):
54855484
plt.plot(None)
54865485
with pytest.raises(ValueError):
54875486
plt.plot(None, None)
5487+
with pytest.raises(ValueError):
5488+
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))
54885489

54895490

54905491
@pytest.mark.parametrize(
@@ -6227,11 +6228,6 @@ def test_empty_errorbar_legend():
62276228
ax.legend()
62286229

62296230

6230-
def test_plot_columns_cycle_deprecation():
6231-
with pytest.warns(MatplotlibDeprecationWarning):
6232-
plt.plot(np.zeros((2, 2)), np.zeros((2, 3)))
6233-
6234-
62356231
@check_figures_equal(extensions=["png"])
62366232
def test_plot_decimal(fig_test, fig_ref):
62376233
x0 = np.arange(-10, 10, 0.3)

0 commit comments

Comments
 (0)