8000 Simplify try...except and add additional comment · matplotlib/matplotlib@6365ae5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6365ae5

Browse files
committed
Simplify try...except and add additional comment
1 parent 5f66d83 commit 6365ae5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,11 +1323,8 @@ def _check_1d(x):
13231323
"always",
13241324
category=Warning,
13251325
message='Support for multi-dimensional indexing')
1326-
try:
1327-
ndim = x[:, None].ndim
1328-
except AssertionError:
1329-
# catch https://github.com/pandas-dev/pandas/issues/35527
1330-
return np.asanyarray(x)
1326+
1327+
ndim = x[:, None].ndim
13311328
# we have definitely hit a pandas index or series object
13321329
# cast to a numpy array.
13331330
if len(w) > 0:
@@ -1338,7 +1335,10 @@ def _check_1d(x):
13381335
if ndim < 2:
13391336
return np.atleast_1d(x)
13401337
return x
1341-
except (IndexError, TypeError):
1338+
# In pandas 1.1.0, multidimensional indexing leads to an AssertionError for some
1339+
# Series objects, but should be IndexError as described in
1340+
# https://github.com/pandas-dev/pandas/issues/35527
1341+
except (AssertionError, IndexError, TypeError):
13421342
return np.atleast_1d(x)
13431343

13441344

0 commit comments

Comments
 (0)
0