-
Notifications
You must be signed in to change notification settings - Fork 7.1k
port tests in test_functional_tensor to pytest #3977
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
port tests in test_functional_tensor to pytest #3977
Conversation
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 @sahilg06 ! This looks great, I only have some minor cosmetics comments, but LGTM when green!
test/test_functional_tensor.py
Outdated
@@ -1141,5 +1003,148 @@ def test_adjust_gamma(device, dtype, config): | |||
) | |||
|
|||
|
|||
@pytest.mark.parametrize('device', cpu_and_gpu()) | |||
@pytest.mark.parametrize('func, args', [(F_t._get_image_size, ()), (F_t.vflip, ()), |
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.
It's no big deal but I find this formatting to be a bit cleaner, and easier to read:
@pytest.mark.parametrize('func, args', [
(F_t._get_image_size, ()),
(F_t.vflip, ()),
(F_t.hflip, ()),
(F_t.crop, (1, 2, 4, 5)),
(F_t.adjust_brightness, (0., )),
(F_t.adjust_contrast, (1., )),
...
])
test/test_functional_tensor.py
Outdated
|
||
|
||
@pytest.mark.parametrize('device', cpu_and_gpu()) | ||
@pytest.mark.parametrize('top,left,height,width', [(1, 2, 4, 5), # crop inside top-left corner |
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.
We could do something similar here
test/test_functional_tensor.py
Outdated
if image_size == 'small': | ||
|
||
tensor = torch.from_numpy( | ||
np.arange(3 * 10 * 12, dtype="uint8").reshape((10, 12, 3)) | ||
).permute(2, 0, 1).to(device) | ||
|
||
else: |
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.
no need to skip lines here:
if image_size == 'small': | |
tensor = torch.from_numpy( | |
np.arange(3 * 10 * 12, dtype="uint8").reshape((10, 12, 3)) | |
).permute(2, 0, 1).to(device) | |
else: | |
if image_size == 'small': | |
tensor = torch.from_numpy( | |
np.arange(3 * 10 * 12, dtype="uint8").reshape((10, 12, 3)) | |
).permute(2, 0, 1).to(device) | |
else: |
Yes ;), I tend to approve early when the requested changes are easy / obvious. I sometimes make comments that don't really need to be addressed and for those I usually say they're Nits. The comments here were bordeline nits. Thanks a lot for the PR! |
Reviewed By: NicolasHug Differential Revision: D29027349 fbshipit-source-id: dcf94ab9ba52af22b3274edc96f70ac66ae9f397
Refactored the following tests to pytest in the file test/test_functional_tensor.py mentioned in issue #3956
Group A
Group E