-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Added get_shape as an alias for get_size + tests #25425
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
Changes from all commits
41aba54
bfd3ccf
86c5063
ca54ced
076e3c1
34dc0da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1468,3 +1468,15 @@ def test__resample_valid_output(): | |||||||
resample(np.zeros((9, 9), np.uint8), np.zeros((9, 9))) | ||||||||
with pytest.raises(ValueError, match="must be C-contiguous"): | ||||||||
resample(np.zeros((9, 9)), np.zeros((9, 9)).T) | ||||||||
|
||||||||
|
||||||||
def test_axesimage_get_shape(): | ||||||||
# generate dummy image to test get_shape method | ||||||||
ax = plt.gca() | ||||||||
im = AxesImage(ax) | ||||||||
oscargus marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
with pytest.raises(RuntimeError, match="You must first set the image array"): | ||||||||
im.get_shape() | ||||||||
z = np.arange(12, dtype=float).reshape((4, 3)) | ||||||||
im.set_data(z) | ||||||||
assert im.get_shape() == (4, 3) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On one hand, this is testing two things so not technically a unit test. On the other hand all of our tests have a high aspect of integration testing to them (e.g. this test invokes
Suggested change
|
||||||||
assert im.get_size() == im.get_shape() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could save having the RuntimeError repeated by making
get_size
callget_shape
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, @jklymak @tacaswell. I decided to merge the tests and add the exception test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that you actually did this....