8000 add __repr__ to GridSpecBase · matplotlib/matplotlib@6cde4bf · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6cde4bf

Browse files
committed
add __repr__ to GridSpecBase
1 parent d4f1f8d commit 6cde4bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/matplotlib/gridspec.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None):
4444
self.set_height_ratios(height_ratios)
4545
self.set_width_ratios(width_ratios)
4646

47+
def __repr__(self):
48+
height_arg = (', height_ratios=%r' % self._row_height_ratios
49+
if self._row_height_ratios is not None else '')
50+
width_arg = (', width_ratios=%r' % self._col_width_ratios
51+
if self._col_width_ratios is not None else '')
52+
return '{clsname}({nrows}, {ncols}{optionals})'.format(
53+
clsname=self.__class__.__name__,
54+
nrows=self._nrows,
55+
ncols=self._ncols,
56+
optionals=height_arg + width_arg,
57+
)
58+
4759
def get_geometry(self):
4860
'get the geometry of the grid, e.g., 2,3'
4961
return self._nrows, self._ncols

0 commit comments

Comments
 (0)
0