8000 Added the old test back in to prevent error handling change. Also uni… · matplotlib/matplotlib@8a722c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a722c1

Browse files
committed
Added the old test back in to prevent error handling change. Also unit test!
1 parent b3021dc commit 8a722c1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ def figaspect(arg):
17581758
Thanks to Fernando Perez for this function
17591759
"""
17601760

1761-
isarray = not np.isscalar(arg)
1761+
isarray = hasattr(arg, 'shape') and not np.isscalar(arg)
17621762

17631763
# min/max sizes to respect when autoscaling. If John likes the idea, they
17641764
# could become rc parameters, for now they're hardwired.

lib/matplotlib/tests/test_figure.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from matplotlib.testing.decorators import image_comparison, cleanup
99
from matplotlib.axes import Axes
1010
import matplotlib.pyplot as plt
11-
11+
import numpy as np
1212

1313
@cleanup
1414
def test_figure_label():
@@ -191,6 +191,17 @@ def test_axes_remove():
191191
assert_equal(len(fig.axes), 3)
192192

193193

194+
def test_figaspect():
195+
w, h = plt.figaspect(np.float64(2) / np.float64(1))
196+
assert h / w == 2
197+
w, h = plt.figaspect(2)
198+
assert h / w == 2
199+
w, h = plt.figaspect(np.zeros((1, 2)))
200+
assert h / w == 0.5
201+
w, h = plt.figaspect(np.zeros((2, 2)))
202+
assert h / w == 1
203+
204+
194205
if __name__ == "__main__":
195206
import nose
196207
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)
0