8000 Better test for isarray in figaspect(). Closes #5464. by WeatherGod · Pull Request #5465 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Better test for isarray in figaspect(). Closes #5464. #5465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
10000 Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added the old test back in to prevent error handling change. Also uni…
…t test!
  • Loading branch information
WeatherGod committed Nov 12, 2015
commit 47fb83ab68f85933043705ac2bea2e1a0b1b55ff
2 changes: 1 addition & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ def figaspect(arg):
Thanks to Fernando Perez for this function
"""

isarray = not np.isscalar(arg)
isarray = hasattr(arg, 'shape') and not np.isscalar(arg)

# min/max sizes to respect when autoscaling. If John likes the idea, they
# could become rc parameters, for now they're hardwired.
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from matplotlib.testing.decorators import image_comparison, cleanup
from matplotlib.axes import Axes
import matplotlib.pyplot as plt
import numpy as np


@cleanup
Expand Down Expand Up @@ -191,6 +192,17 @@ def test_axes_remove():
assert_equal(len(fig.axes), 3)


def test_figaspect():
w, h = plt.figaspect(np.float64(2) / np.float64(1))
assert h / w == 2
w, h = plt.figaspect(2)
assert h / w == 2
w, h = plt.figaspect(np.zeros((1, 2)))
assert h / w == 0.5
w, h = plt.figaspect(np.zeros((2, 2)))
assert h / w == 1


if __name__ == "__main__":
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
0