File tree 3 files changed +26
-4
lines changed
doc/api/next_api_changes/deprecations
3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change
1
+ ``Line2D ``
2
+ ~~~~~~~~~~
3
+ When creating a Line2D or using `.Line2D.set_xdata ` and `.Line2D.set_ydata `,
4
+ passing x/y data as non sequence is deprecated.
Original file line number Diff line number Diff line change @@ -1280,7 +1280,14 @@ def set_xdata(self, x):
1280
1280
x : 1D array
1281
1281
"""
1282
1282
if not np .iterable (x ):
1283
- raise RuntimeError ('x must be a sequence' )
1283
+ # When deprecation cycle is completed
1284
+ # raise RuntimeError('x must be a sequence')
1285
+ _api .warn_deprecated (
1286
+ since = 3.7 ,
1287
+ message = "Setting data with a non sequence type "
1288
+ "is deprecated since %(since)s and will be "
1289
+ "remove %(removal)s" )
1290
+ x = [x , ]
1284
1291
self ._xorig = copy .copy (x )
1285
1292
self ._invalidx = True
1286
1293
self .stale = True
@@ -1294,7 +1301,14 @@ def set_ydata(self, y):
1294
1301
y : 1D array
1295
1302
"""
1296
1303
if not np .iterable (y ):
1297
- raise RuntimeError ('y must be a sequence' )
1304
+ # When deprecation cycle is completed
1305
+ # raise RuntimeError('y must be a sequence')
1306
+ _api .warn_deprecated (
1307
+ since = 3.7 ,
1308
+ message = "Setting data with a non sequence type "
1309
+ "is deprecated since %(since)s and will be "
1310
+ "remove %(removal)s" )
1311
+ y = [y , ]
1298
1312
self ._yorig = copy .copy (y )
1299
1313
self ._invalidy = True
1300
1314
self .stale = True
Original file line number Diff line number Diff line change 20
20
import matplotlib .pyplot as plt
21
21
import matplotlib .transforms as mtransforms
22
22
from matplotlib .testing .decorators import image_comparison , check_figures_equal
23
+ from matplotlib ._api .deprecation import MatplotlibDeprecationWarning
23
24
24
25
25
26
def test_segment_hits ():
@@ -91,9 +92,12 @@ def test_invalid_line_data():
91
92
mlines .Line2D ([], 1 )
92
93
93
94
line = mlines .Line2D ([], [])
94
- with pytest .raises (RuntimeError , match = 'x must be' ):
95
+ # when deprecation cycle is completed
96
+ # with pytest.raises(RuntimeError, match='x must be'):
97
+ with pytest .warns (MatplotlibDeprecationWarning ):
95
98
line .set_xdata (0 )
96
- with pytest .raises (RuntimeError , match = 'y must be' ):
99
+ # with pytest.raises(RuntimeError, match='y must be'):
100
+ with pytest .warns (MatplotlibDeprecationWarning ):
97
101
line .set_ydata (0 )
98
102
99
103
You can’t perform that action at this time.
0 commit comments