Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86a86e2

Browse files
committed
Fix cbook._reshape2D for scalar object inputs.
Before the fix, `plt.hist(None)` would fail with `x must have 2 or fewer dimensions`, which it does have. Now it fails with a bit later with `unsupported operands type(s) for +: 'NoneType' and 'float'`, which is hopefully clearer.
1 parent 9a077e8 commit 86a86e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ def _reshape_2D(X, name):
19901990
*name* is used to generate the error message for invalid inputs.
19911991
"""
19921992
# Iterate over columns for ndarrays, over rows otherwise.
1993-
X = X.T if isinstance(X, np.ndarray) else np.asarray(X)
1993+
X = np.atleast_1d(X.T if isinstance(X, np.ndarray) else np.asarray(X))
19941994
if X.ndim == 1 and X.dtype.type != np.object_:
19951995
# 1D array of scalars: directly return it.
19961996
return [X]

0 commit comments

Comments
 (0)