10000 Fix checking of 'labels' argument to Sankey.add. · matplotlib/matplotlib@007dd8b · GitHub
[go: up one dir, main page]

Skip to content

Commit 007dd8b

Browse files
committed
Fix checking of 'labels' argument to Sankey.add.
Test by manually running the sankey examples.
1 parent ddd82b5 commit 007dd8b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/sankey.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from matplotlib.path import Path
1111
from matplotlib.patches import PathPatch
1212
from matplotlib.transforms import Affine2D
13-
from matplotlib import cbook, docstring
13+
from matplotlib import docstring
1414
from matplotlib import rcParams
1515

1616
_log = logging.getLogger(__name__)
@@ -449,13 +449,13 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
449449
"orientations and flows must have the same length.\n"
450450
"orientations has length %d, but flows has length %d."
451451
% (len(orientations), n))
452-
if not cbook.is_scalar_or_string(labels) and len(labels) != n:
452+
try:
453+
labels = np.broadcast_to(labels, n)
454+
except ValueError:
453455
raise ValueError(
454-
"If labels is a list, then labels and flows must have the "
455-
"same length.\nlabels has length %d, but flows has length %d."
456-
% (len(labels), n))
457-
5FF5 else:
458-
labels = [labels] * n
456+
f"The shapes of 'flows' {np.shape(flows)} and 'labels' "
457+
f"{np.shape(labels)} are incompatible"
458+
) from None
459459
if trunklength < 0:
460460
raise ValueError(
461461
"trunklength is negative.\nThis isn't allowed, because it would "

0 commit comments

Comments
 (0)
0