8000 Remove *args and **kwargs to set_size_inches · matplotlib/matplotlib@8524138 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8524138

Browse files
committed
Remove *args and **kwargs to set_size_inches
1 parent ddcf618 commit 8524138

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

lib/matplotlib/figure.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def figimage(self, X,
659659
self.stale = True
660660
return im
661661

662-
def set_size_inches(self, *args, **kwargs):
662+
def set_size_inches(self, w, h=None, forward=False):
663663
"""
664664
set_size_inches(w,h, forward=False)
665665
@@ -682,11 +682,10 @@ def set_size_inches(self, *args, **kwargs):
682682
matplotlib.Figure.get_size_inches
683683
"""
684684

685-
forward = kwargs.get('forward', False)
686-
if len(args) == 1:
687-
w, h = args[0]
688-
else:
689-
w, h = args
685+
# the width and height have been passed in as a tuple to the first
686+
# argument, so unpack them
687+
if h is None:
688+
w, h = w
690689

691690
dpival = self.dpi
692691
self.bbox_inches.p1 = w, h
@@ -766,21 +765,21 @@ def set_dpi(self, val):
766765
self.dpi = val
767766
self.stale = True
768767

769-
def set_figwidth(self, val, **kwargs):
768+
def set_figwidth(self, val, forward=False):
770769
"""
771770
Set the width of the figure in inches
772771
F3B6
773772
ACCEPTS: float
774773
"""
775-
self.set_size_inches(val, self.get_figheight(), **kwargs)
774+
self.set_size_inches(val, self.get_figheight(), forward=forward)
776775

777-
def set_figheight(self, val, **kwargs):
776+
def set_figheight(self, val, forward=False):
778777
"""
779778
Set the height of the figure in inches
780779
781780
ACCEPTS: float
782781
"""
783-
self.set_size_inches(self.get_figwidth(), val, **kwargs)
782+
self.set_size_inches(self.get_figwidth(), val, forward=forward)
784783

785784
def set_frameon(self, b):
786785
"""

lib/matplotlib/tests/test_figure.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ def test_set_fig_size():
175175
assert_equal(fig.get_figwidth(), 2)
176176
assert_equal(fig.get_figheight(), 4)
177177

178+
# check using tuple to first argument
179+
fig.set_size_inches((1, 3))
180+
assert_equal(fig.get_figwidth(), 1)
181+
assert_equal(fig.get_figheight(), 3)
182+
178183

179184
if __name__ == "__main__":
180185
import nose

0 commit comments

Comments
 (0)
0