File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1758,7 +1758,7 @@ def figaspect(arg):
1758
1758
Thanks to Fernando Perez for this function
1759
1759
"""
1760
1760
1761
- isarray = hasattr (arg , 'shape' )
1761
+ isarray = hasattr (arg , 'shape' ) and not np . isscalar ( arg )
1762
1762
1763
1763
# min/max sizes to respect when autoscaling. If John likes the idea, they
1764
1764
# could become rc parameters, for now they're hardwired.
Original file line number Diff line number Diff line change 8
8
from matplotlib .testing .decorators import image_comparison , cleanup
9
9
from matplotlib .axes import Axes
10
10
import matplotlib .pyplot as plt
11
+ import numpy as np
11
12
12
13
13
14
@cleanup
@@ -191,6 +192,17 @@ def test_axes_remove():
191
192
assert_equal (len (fig .axes ), 3 )
192
193
193
194
195
+ def test_figaspect ():
196
+ w , h = plt .figaspect (np .float64 (2 ) / np .float64 (1 ))
197
+ assert h / w == 2
198
+ w , h = plt .figaspect (2 )
199
+ assert h / w == 2
200
+ w , h = plt .figaspect (np .zeros ((1 , 2 )))
201
+ assert h / w == 0.5
202
+ w , h = plt .figaspect (np .zeros ((2 , 2 )))
203
+ assert h / w == 1
204
+
205
+
194
206
if __name__ == "__main__" :
195
207
import nose
196
208
nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
You can’t perform that action at this time.
0 commit comments