From a9523f5fbc9552d088f7759f918d0c1ab766d236 Mon Sep 17 00:00:00 2001 From: rsp2210 Date: Mon, 25 Sep 2023 22:46:28 -0700 Subject: [PATCH] Resolved squash conflict and applied changes --- doc/api/next_api_changes/behavior/26902-RP.rst | 5 +++++ lib/matplotlib/lines.py | 18 ++---------------- lib/matplotlib/tests/test_lines.py | 7 ++----- 3 files changed, 9 insertions(+), 21 deletions(-) create mode 100644 doc/api/next_api_changes/behavior/26902-RP.rst diff --git a/doc/api/next_api_changes/behavior/26902-RP.rst b/doc/api/next_api_changes/behavior/26902-RP.rst new file mode 100644 index 000000000000..3106de94fbd5 --- /dev/null +++ b/doc/api/next_api_changes/behavior/26902-RP.rst @@ -0,0 +1,5 @@ +``Line2D`` +~~~~~~~~~~ + +When creating a Line2D or using `.Line2D.set_xdata` and `.Line2D.set_ydata`, +passing x/y data as non sequence is now an error. diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 92d55a3fe6ae..31b931a52c82 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1276,14 +1276,7 @@ def set_xdata(self, x): x : 1D array """ if not np.iterable(x): - # When deprecation cycle is completed - # raise RuntimeError('x must be a sequence') - _api.warn_deprecated( - since="3.7", - message="Setting data with a non sequence type " - "is deprecated since %(since)s and will be " - "remove %(removal)s") - x = [x, ] + raise RuntimeError('x must be a sequence') self._xorig = copy.copy(x) self._invalidx = True self.stale = True @@ -1297,14 +1290,7 @@ def set_ydata(self, y): y : 1D array """ if not np.iterable(y): - # When deprecation cycle is completed - # raise RuntimeError('y must be a sequence') - _api.warn_deprecated( - since="3.7", - message="Setting data with a non sequence type " - "is deprecated since %(since)s and will be " - "remove %(removal)s") - y = [y, ] + raise RuntimeError('y must be a sequence') self._yorig = copy.copy(y) self._invalidy = True self.stale = True diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index 4f23e6969b0b..68e378a20f88 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -92,12 +92,9 @@ def test_invalid_line_data(): mlines.Line2D([], 1) line = mlines.Line2D([], []) - # when deprecation cycle is completed - # with pytest.raises(RuntimeError, match='x must be'): - with pytest.warns(mpl.MatplotlibDeprecationWarning): + with pytest.raises(RuntimeError, match='x must be'): line.set_xdata(0) - # with pytest.raises(RuntimeError, match='y must be'): - with pytest.warns(mpl.MatplotlibDeprecationWarning): + with pytest.raises(RuntimeError, match='y must be'): line.set_ydata(0)