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

Skip to content

Commit 98f22a9

Browse files
committed
Error out of index_of if input is not a NumPy array.
1 parent a0aac5a commit 98f22a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,15 @@ def index_of(y):
16061606
try:
16071607
return y.index.values, y.values
16081608
except AttributeError:
1609+
pass
1610+
try:
16091611
y = _check_1d(y)
1612+
except (np.VisibleDeprecationWarning, ValueError):
1613+
# NumPy 1.19 will warn on ragged input, and we can't actually use it.
1614+
pass
1615+
else:
16101616
return np.arange(y.shape[0], dtype=float), y
1617+
raise ValueError('Input could not be cast to an at-least-1D NumPy array')
16111618

16121619

16131620
def safe_first_element(obj):

0 commit comments

Comments
 (0)