File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1416,6 +1416,8 @@ def _reshape_2D(X, name):
1416
1416
"""
1417
1417
# Iterate over columns for ndarrays, over rows otherwise.
1418
1418
X = np .atleast_1d (X .T if isinstance (X , np .ndarray ) else np .asarray (X ))
1419
+ if len (X ) == 0 :
1420
+ return [[]]
1419
1421
if X .ndim == 1 and not isinstance (X [0 ], collections .abc .Iterable ):
1420
1422
# 1D array of scalars: directly return it.
1421
1423
return [X ]
Original file line number Diff line number Diff line change @@ -495,7 +495,11 @@ def test_flatiter():
495
495
def test_reshape2d ():
496
496
class dummy ():
497
497
pass
498
+ xnew = cbook ._reshape_2D ([], 'x' )
499
+ assert np .shape (xnew ) == (1 , 0 )
500
+
498
501
x = [dummy () for j in range (5 )]
502
+
499
503
xnew = cbook ._reshape_2D (x , 'x' )
500
504
assert np .shape (xnew ) == (1 , 5 )
501
505
You can’t perform that action at this time.
0 commit comments