Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86a86e2

Browse files
committed
Fix cbook._reshape2D for scalar object inputs.
Before the fix, `plt.hist(None)` would fail with `x must have 2 or fewerdimensions`, which it does have. Now it fails with a bit later with`unsupported operands type(s) for +: 'NoneType' and 'float'`, which ishopefully clearer.
1 parent9a077e8 commit86a86e2

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.Tifisinstance(X,np.ndarray)elsenp.asarray(X)
1993+
X=np.atleast_1d(X.Tifisinstance(X,np.ndarray)elsenp.asarray(X))
19941994
ifX.ndim==1andX.dtype.type!=np.object_:
19951995
# 1D array of scalars: directly return it.
19961996
return [X]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp