Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better handling of scalars to plt.subplot(). Fixes #880 #1092

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 1 commit into from
May 14, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from nose.tools import assert_equal
import numpy as np
from numpy import ma

import matplotlib
from matplotlib.testing.decorators import image_comparison, cleanup
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -1279,6 +1281,12 @@ def test_mixed_collection():
ax.set_xlim(0, 16)
ax.set_ylim(0, 16)

@cleanup
def test_subplot_key_hash():
ax = plt.subplot(np.float64(5.5), np.int64(1), np.float64(1.2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it not make more sense to raise an exception immediately if subplot args are not integer values (though perhaps not necessarily integer dtypes)? I don't see how a value like 5.5 can be anything but a programming error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to agree. It would break backwards compatibility though, as passing a python float is currently handled by casting to an int. This approach doesn't break that "feature". Preferences?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a spurious feature at best. I understand it breaks backward compatibility -- but if a float is being passed in, I think it's better to let the user know there was a mistake. We can add a CHANGELOG entry to this effect.

ax.twinx()
assert_equal((5, 1, 0, None), ax.get_subplotspec().get_geometry())


if __name__ == '__main__':
import nose
Expand Down