1919License : matplotlib license
2020
2121"""
22- from __future__ import (absolute_import , division , print_function ,
23- unicode_literals )
24-
25- import six
26-
2722import warnings
2823
2924from . import artist
3732
3833class Cell (Rectangle ):
3934 """
40- A cell is a Rectangle with some associated text.
41-
35+ A cell is a `.Rectangle` with some associated text.
4236 """
4337 PAD = 0.1 # padding between text and rectangle
4438
@@ -73,15 +67,15 @@ def set_figure(self, fig):
7367 self ._text .set_figure (fig )
7468
7569 def get_text (self ):
76- ' Return the cell Text intance'
70+ """ Return the cell `. Text` instance."""
7771 return self ._text
7872
7973 def set_fontsize (self , size ):
8074 self ._text .set_fontsize (size )
8175 self .stale = True
8276
8377 def get_fontsize (self ):
84- ' Return the cell fontsize'
78+ """ Return the cell fontsize."""
8579 return self ._text .get_fontsize ()
8680
8781 def auto_set_font_size (self , renderer ):
@@ -189,8 +183,9 @@ def visible_edges(self, value):
189183 self .stale = True
190184
191185 def get_path (self ):
192- 'Return a path where the edges specified by _visible_edges are drawn'
193-
186+ """
187+ Return a path where the edges specified by _visible_edges are drawn.
188+ """
194189 codes = [Path .MOVETO ]
195190
196191 for edge in self ._edges :
@@ -249,12 +244,12 @@ def __init__(self, ax, loc=None, bbox=None, **kwargs):
249244
250245 Artist .__init__ (self )
251246
252- if isinstance (loc , six . string_types ) and loc not in self .codes :
247+ if isinstance (loc , str ) and loc not in self .codes :
253248 warnings .warn ('Unrecognized location %s. Falling back on '
254249 'bottom; valid locations are\n %s\t ' %
255250 (loc , '\n \t ' .join (self .codes )))
256251 loc = 'bottom'
257- if isinstance (loc , six . string_types ):
252+ if isinstance (loc , str ):
258253 loc = self .codes .get (loc , 1 )
259254 self .set_figure (ax .figure )
260255 self ._axes = ax
@@ -281,9 +276,9 @@ def add_cell(self, row, col, *args, **kwargs):
281276 Parameters
282277 ----------
283278 row : int
284- Row index
279+ Row index.
285280 col : int
286- Column index
281+ Column index.
287282
288283 Returns
289284 -------
@@ -297,7 +292,7 @@ def add_cell(self, row, col, *args, **kwargs):
297292
298293 def __setitem__ (self , position , cell ):
299294 """
300- Set a customcell in a given position
295+ Set a custom cell in a given position.
301296 """
302297 if not isinstance (cell , CustomCell ):
303298 raise TypeError ('Table only accepts CustomCell' )
@@ -313,7 +308,7 @@ def __setitem__(self, position, cell):
313308
314309 def __getitem__ (self , position ):
315310 """
316- Retreive a custom cell from a given position
311+ Retrieve a custom cell from a given position.
317312 """
318313 try :
319314 row , col = position [0 ], position [1 ]
@@ -359,7 +354,7 @@ def _get_grid_bbox(self, renderer):
359354
360355 Only include those in the range (0,0) to (maxRow, maxCol)"""
361356 boxes = [cell .get_window_extent (renderer )
362- for (row , col ), cell in six . iteritems ( self ._cells )
357+ for (row , col ), cell in self ._cells . items ( )
363358 if row >= 0 and col >= 0 ]
364359 bbox = Bbox .union (boxes )
365360 return bbox .inverse_transformed (self .get_transform ())
@@ -377,22 +372,22 @@ def contains(self, mouseevent):
377372 renderer = self .figure ._cachedRenderer
378373 if renderer is not None :
379374 boxes = [cell .get_window_extent (renderer )
380- for (row , col ), cell in six . iteritems ( self ._cells )
375+ for (row , col ), cell in self ._cells . items ( )
381376 if row >= 0 and col >= 0 ]
382377 bbox = Bbox .union (boxes )
383378 return bbox .contains (mouseevent .x , mouseevent .y ), {}
384379 else :
385380 return False , {}
386381
387382 def get_children (self ):
388- ' Return the Artists contained by the table'
389- return list (six . itervalues ( self ._cells ))
383+ """ Return the Artists contained by the table."""
384+ return list (self ._cells . values ( ))
390385 get_child_artists = get_children # backward compatibility
391386
392387 def get_window_extent (self , renderer ):
393- ' Return the bounding box of the table in window coords'
388+ """ Return the bounding box of the table in window coords."""
394389 boxes = [cell .get_window_extent (renderer )
395- for cell in six . itervalues ( self ._cells )]
390+ for cell in self ._cells . values ( )]
396391 return Bbox .union (boxes )
397392
398393 def _do_cell_alignment (self ):
@@ -403,7 +398,7 @@ def _do_cell_alignment(self):
403398 # Calculate row/column widths
404399 widths = {}
405400 heights = {}
406- for (row , col ), cell in six . iteritems ( self ._cells ):
401+ for (row , col ), cell in self ._cells . items ( ):
407402 height = heights .setdefault (row , 0.0 )
408403 heights [row ] = max (height , cell .get_height ())
409404 width = widths .setdefault (col , 0.0 )
@@ -423,7 +418,7 @@ def _do_cell_alignment(self):
423418 ypos += heights [row ]
424419
425420 # set cell positions
426- for (row , col ), cell in six . iteritems ( self ._cells ):
421+ for (row , col ), cell in self ._cells . items ( ):
427422 cell .set_x (lefts [col ])
428423 cell .set_y (bottoms [row ])
429424
@@ -461,8 +456,7 @@ def auto_set_column_width(self, col):
461456 self .stale = True
462457
463458 def _auto_set_column_width (self , col , renderer ):
464- """ Automagically set width for column.
465- """
459+ """Automatically set width for column."""
466460 cells = [key for key in self ._cells if key [1 ] == col ]
467461
468462 # find max width
@@ -484,9 +478,9 @@ def _auto_set_font_size(self, renderer):
484478
485479 if len (self ._cells ) == 0 :
486480 return
487- fontsize = list ( six . itervalues (self ._cells ))[ 0 ] .get_fontsize ()
481+ fontsize = next ( iter (self ._cells . values ())) .get_fontsize ()
488482 cells = []
489- for key , cell in six . iteritems ( self ._cells ):
483+ for key , cell in self ._cells . items ( ):
490484 # ignore auto-sized columns
491485 if key [1 ] in self ._autoColumns :
492486 continue
@@ -495,12 +489,12 @@ def _auto_set_font_size(self, renderer):
495489 cells .append (cell )
496490
497491 # now set all fontsizes equal
498- for cell in six . itervalues ( self ._cells ):
492+ for cell in self ._cells . values ( ):
499493 cell .set_fontsize (fontsize )
500494
501495 def scale (self , xscale , yscale ):
502496 """ Scale column widths by xscale and row heights by yscale. """
503- for c in six . itervalues ( self ._cells ):
497+ for c in self ._cells . values ( ):
504498 c .set_width (c .get_width () * xscale )
505499 c .set_height (c .get_height () * yscale )
506500
@@ -511,14 +505,13 @@ def set_fontsize(self, size):
511505 ACCEPTS: a float in points
512506 """
513507
514- for cell in six . itervalues ( self ._cells ):
508+ for cell in self ._cells . values ( ):
515509 cell .set_fontsize (size )
516510 self .stale = True
517511
518512 def _offset (self , ox , oy ):
519- 'Move all the artists by ox,oy (axes coords)'
520-
521- for c in six .itervalues (self ._cells ):
513+ """Move all the artists by ox, oy (axes coords)."""
514+ for c in self ._cells .values ():
522515 x , y = c .get_x (), c .get_y ()
523516 c .set_x (x + ox )
524517 c .set_y (y + oy )
@@ -579,7 +572,7 @@ def _update_positions(self, renderer):
579572 self ._offset (ox , oy )
580573
581574 def get_celld (self ):
582- 'return a dict of cells in the table'
575+ """Return a dict of cells in the table."""
583576 return self ._cells
584577
585578
0 commit comments