File tree Expand file tree Collapse file tree 4 files changed +11
-20
lines changed
Filter options
examples/text_labels_and_annotations Expand file tree Collapse file tree 4 files changed +11
-20
lines changed
Original file line number Diff line number Diff line change @@ -147,19 +147,16 @@ def do_fontsize(k):
147
147
148
148
if normalize_data :
149
149
# find maximum value for rates, i.e. where keys are 2 chars long
150
- max_val = 0
151
- for k , v in data .items ():
152
- if len (k ) == 2 :
153
- max_val = max (max_val , v )
150
+ max_val = max ((v for k , v in data .items () if len (k ) == 2 ), default = 0 )
154
151
# divide rates by max val, multiply by arrow scale factor
155
152
for k , v in data .items ():
156
153
data [k ] = v / max_val * sf
157
154
158
155
def draw_arrow (pair , alpha = alpha , ec = ec , labelcolor = labelcolor ):
159
156
# set the length of the arrow
160
157
if display == 'length' :
161
- length = max_head_length + data [ pair ] / sf * ( max_arrow_length -
162
- max_head_length )
158
+ length = ( max_head_length
159
+ + data [ pair ] / sf * ( max_arrow_length - max_head_length ) )
163
160
else :
164
161
length = max_arrow_length
165
162
# set the transparency of the arrow
Original file line number Diff line number Diff line change @@ -657,7 +657,7 @@ def set_data(self, *args):
657
657
*args : (N, 2) array or two 1D arrays
658
658
"""
659
659
if len (args ) == 1 :
660
- x , y = args [ 0 ]
660
+ ( x , y ), = args
661
661
else :
662
662
x , y = args
663
663
@@ -763,8 +763,8 @@ def draw(self, renderer):
763
763
self .ind_offset = 0 # Needed for contains() method.
764
764
if self ._subslice and self .axes :
765
765
x0 , x1 = self .axes .get_xbound ()
766
- i0 , = self ._x_filled .searchsorted ([ x0 ] , 'left' )
767
- i1 , = self ._x_filled .searchsorted ([ x1 ] , 'right' )
766
+ i0 = self ._x_filled .searchsorted (x0 , 'left' )
767
+ i1 = self ._x_filled .searchsorted (x1 , 'right' )
768
768
subslice = slice (max (i0 - 1 , 0 ), i1 + 1 )
769
769
self .ind_offset = subslice .start
770
770
self ._transform_path (subslice )
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ def iter_style_files(style_dir):
178
178
if is_style_file (filename ):
179
179
match = STYLE_FILE_PATTERN .match (filename )
180
180
path = os .path .abspath (os .path .join (style_dir , path ))
181
- yield path , match .groups ()[ 0 ]
181
+ yield path , match .group ( 0 )
182
182
183
183
184
184
def read_style_directory (style_dir ):
Original file line number Diff line number Diff line change @@ -518,17 +518,11 @@ def auto_set_column_width(self, col):
518
518
519
519
def _auto_set_column_width (self , col , renderer ):
520
520
"""Automatically set width for column."""
521
- cells = [key for key in self ._cells if key [1 ] == col ]
522
-
523
- # find max width
524
- width = 0
525
- for cell in cells :
526
- c = self ._cells [cell ]
527
- width = max (c .get_required_width (renderer ), width )
528
-
529
- # Now set the widths
521
+ cells = [cell for key , cell in self ._cells .items () if key [1 ] == col ]
522
+ max_width = max ((cell .get_required_width (renderer ) for cell in cells ),
523
+ default = 0 )
530
524
for cell in cells :
531
- self . _cells [ cell ] .set_width (width )
525
+ cell .set_width (max_width )
532
526
533
527
def auto_set_font_size (self , value = True ):
534
528
""" Automatically set font size. """
You can’t perform that action at this time.
0 commit comments