Skip to content

Commit 73ab7fa

Browse files
committed
Force ragged lists into object-arrays in _reshape_2D.
Unfortunately, callers to this function allow both styles and we need to accept them and cast to continue supporting it.
1 parent c06ba77 commit 73ab7fa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,16 @@ def _reshape_2D(X, name):
13331333
*name* is used to generate the error message for invalid inputs.
13341334
"""
13351335
# Iterate over columns for ndarrays, over rows otherwise.
1336-
X = np.atleast_1d(X.T if isinstance(X, np.ndarray) else np.asarray(X))
1336+
if isinstance(X, np.ndarray):
1337+
X = X.T
1338+
else:
1339+
try:
1340+
X = np.asarray(X)
1341+
except np.VisibleDeprecationWarning:
1342+
# NumPy 1.19 does not allow implicit ragged-array conversion,
1343+
# but callers to this function do.
1344+
X = np.asarray(X, dtype=object)
1345+
X = np.atleast_1d(X)
13371346
if len(X) == 0:
13381347
return [[]]
13391348
elif X.ndim == 1 and np.ndim(X[0]) == 0:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy