@@ -122,20 +122,19 @@ def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25,
122
122
# Check the arguments.
123
123
if gap < 0 :
124
124
raise ValueError (
125
- "The gap is negative. \n This isn't allowed because it "
126
- "would cause the paths to overlap. " )
125
+ "' gap' is negative, which is not allowed because it would "
126
+ " cause the paths to overlap" )
127
127
if radius > gap :
128
128
raise ValueError (
129
- "The inner radius is greater than the path spacing. \n "
130
- "This isn't allowed because it would cause the paths to overlap. " )
129
+ "' radius' is greater than 'gap', which is not allowed because "
130
+ " it would cause the paths to overlap" )
131
131
if head_angle < 0 :
132
132
raise ValueError (
133
- "The angle is negative.\n This isn't allowed "
134
- "because it would cause inputs to look like "
135
- "outputs and vice versa." )
133
+ "'head_angle' is negative, which is not allowed because it "
134
+ "would cause inputs to look like outputs and vice versa" )
136
135
if tolerance < 0 :
137
136
raise ValueError (
138
- "The tolerance is negative. \n It must be a magnitude. " )
137
+ "' tolerance' is negative, but it must be a magnitude" )
139
138
140
139
# Create axes if necessary.
141
140
if ax is None :
@@ -451,18 +450,17 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
451
450
% (len (orientations ), n ))
452
451
if not cbook .is_scalar_or_string (labels ) and len (labels ) != n :
453
452
raise ValueError (
454
- "If labels is a list, then labels and flows must have the "
455
- "same length.\n labels has length %d, but flows has length %d."
456
- % (len (labels ), n ))
453
+ f"The lengths of 'flows' ({ n } ) and 'labels' ({ len (labels )} ) "
454
+ f"are incompatible" )
457
455
else :
458
456
labels = [labels ] * n
459
457
if trunklength < 0 :
460
458
raise ValueError (
461
- " trunklength is negative. \n This isn't allowed, because it would "
462
- " cause poor layout. " )
459
+ "' trunklength' is negative, which is not allowed because it "
460
+ "would cause poor layout" )
463
461
if np .abs (np .sum (flows )) > self .tolerance :
464
462
_log .info ("The sum of the flows is nonzero (%f).\n Is the "
465
- "system not at steady state?" , np .sum (flows ))
463
+ "system not at steady state?" , np .sum (flows ))
466
464
scaled_flows = self .scale * flows
467
465
gain = sum (max (flow , 0 ) for flow in scaled_flows )
468
466
loss = sum (min (flow , 0 ) for flow in scaled_flows )
@@ -478,36 +476,34 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
478
476
" that the scaled sum is approximately 1.0." , gain )
479
477
if prior is not None :
480
478
if prior < 0 :
481
- raise ValueError ("The index of the prior diagram is negative. " )
479
+ raise ValueError ("The index of the prior diagram is negative" )
482
480
if min (connect ) < 0 :
483
481
raise ValueError (
484
- "At least one of the connection indices is negative. " )
482
+ "At least one of the connection indices is negative" )
485
483
if prior >= len (self .diagrams ):
486
484
raise ValueError (
487
- "The index of the prior diagram is %d, but there are "
488
- "only %d other diagrams.\n The index is zero-based."
489
- % (prior , len (self .diagrams )))
485
+ f"The index of the prior diagram is { prior } , but there "
486
+ f"are only { len (self .diagrams )} other diagrams" )
490
487
if connect [0 ] >= len (self .diagrams [prior ].flows ):
491
488
raise ValueError (
492
- "The connection index to the source diagram is %d , but "
493
- "that diagram has only %d flows. \n The index is zero-based."
494
- % ( connect [0 ], len (self .diagrams [prior ].flows )))
489
+ "The connection index to the source diagram is {} , but "
490
+ "that diagram has only {} flows" . format (
491
+ connect [0 ], len (self .diagrams [prior ].flows )))
495
492
if connect [1 ] >= n :
496
493
raise ValueError (
497
- "The connection index to this diagram is %d, but this diagram"
498
- "has only %d flows.\n The index is zero-based."
499
- % (connect [1 ], n ))
494
+ f"The connection index to this diagram is { connect [1 ]} , "
495
+ f"but this diagram has only { n } flows" )
500
496
if self .diagrams [prior ].angles [connect [0 ]] is None :
501
497
raise ValueError (
502
- "The connection cannot be made. Check that the magnitude "
503
- " of flow %d of diagram %d is greater than or equal to the "
504
- "specified tolerance." % ( connect [ 0 ], prior ) )
498
+ f "The connection cannot be made, which may occur if the "
499
+ f"magnitude of flow { connect [ 0 ] } of diagram { prior } is "
500
+ f"less than the specified tolerance" )
505
501
flow_error = (self .diagrams [prior ].flows [connect [0 ]] +
506
502
flows [connect [1 ]])
507
503
if abs (flow_error ) >= self .tolerance :
508
504
raise ValueError (
509
- "The scaled sum of the connected flows is %f, which is not "
510
- "within the tolerance (%f)." % ( flow_error , self .tolerance ) )
505
+ f "The scaled sum of the connected flows is { flow_error } , "
506
+ f"which is not within the tolerance ( { self .tolerance } )" )
511
507
512
508
# Determine if the flows are inputs.
513
509
are_inputs = [None ] * n
@@ -537,8 +533,8 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
537
533
else :
538
534
if orient != - 1 :
539
535
raise ValueError (
540
- "The value of orientations[%d ] is %d , "
541
- "but it must be [ -1 | 0 | 1 ]." % ( i , orient ) )
536
+ f "The value of orientations[{ i } ] is { orient } , "
537
+ f "but it must be -1, 0, or 1" )
542
538
if is_input :
543
539
angles [i ] = UP
544
540
elif not is_input :
@@ -548,9 +544,8 @@ def add(self, patchlabel='', flows=None, orientations=None, labels='',
548
544
if np .iterable (pathlengths ):
549
545
if len (pathlengths ) != n :
550
546
raise ValueError (
551
- "If pathlengths is a list, then pathlengths and flows must "
552
- "have the same length.\n pathlengths has length %d, but flows "
553
- "has length %d." % (len (pathlengths ), n ))
547
+ f"The lengths of 'flows' ({ n } ) and 'pathlengths' "
548
+ f"({ len (pathlengths )} ) are incompatible" )
554
549
else : # Make pathlengths into a list.
555
550
urlength = pathlengths
556
551
ullength = pathlengths
0 commit comments