Backport PR #25196: Add deprecation for setting data with non sequenc… · fedora-python/matplotlib@f78e8ec · GitHub
Skip to content

Commit f78e8ec

Browse files
Backport PR matplotlib#25196: Add deprecation for setting data with non sequence type in Line2D (matplotlib#25201)
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
1 parent 172ede3 commit f78e8ec

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

Lines changed: 4 additions & 0 deletions

lib/matplotlib/lines.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,14 @@ def set_xdata(self, x):
12751275
x : 1D array
12761276
"""
12771277
if not np.iterable(x):
1278-
raise RuntimeError('x must be a sequence')
1278+
# When deprecation cycle is completed
1279+
# raise RuntimeError('x must be a sequence')
1280+
_api.warn_deprecated(
1281+
since=3.7,
1282+
message="Setting data with a non sequence type "
1283+
"is deprecated since %(since)s and will be "
1284+
"remove %(removal)s")
1285+
x = [x, ]
12791286
self._xorig = copy.copy(x)
12801287
self._invalidx = True
12811288
self.stale = True
@@ -1289,7 +1296,14 @@ def set_ydata(self, y):
12891296
y : 1D array
12901297
"""
12911298
if not np.iterable(y):
1292-
raise RuntimeError('y must be a sequence')
1299+
# When deprecation cycle is completed
1300+
# raise RuntimeError('y must be a sequence')
1301+
_api.warn_deprecated(
1302+
since=3.7,
1303+
message="Setting data with a non sequence type "
1304+
"is deprecated since %(since)s and will be "
1305+
"remove %(removal)s")
1306+
y = [y, ]
12931307
self._yorig = copy.copy(y)
12941308
self._invalidy = True
12951309
self.stale = True

lib/matplotlib/tests/test_lines.py

Lines changed: 6 additions & 2 deletions

0 commit comments

Comments
 (0)