-
Notifications
You must be signed in to change notification settings - Fork 7k
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 test/test_transforms.py to pytest #3945
Comments
I am working on group P. |
Thanks for mentioning @NicolasHug. I will try working on Group O. |
Thanks for mentioning @NicolasHug :) I will try working on Group A. |
Hi @NicolasHug, I'd like to work on Group I and J. |
@NicolasHug I can help review. Just ping me. |
Hi @NicolasHug, I'll try working on Group N |
Hey @NicolasHug, I will try working on Group F. |
Hi @NicolasHug, I will try working on Group K. |
Hi @NicolasHug, I will try working on Group E. |
For b,c,d,g groups i will raise PR |
Thanks @harishsdev! please make sure to submit at most 2 groups per PR to keep the review manageable :) |
Hi @NicolasHug, I will try working on Group M. |
@NicolasHug in function test_rotate_fill in group K . Do I need to parameterize any variable as there are 2 for loops but 1 is dependent on the other. Please guide. |
Ah, I wish we could have covariant parametrization! This is a common struggle. |
Seems like most groups have been taken already, thanks everyone for your interest! I've created another similar issue for those who are interested: #3956 |
@NicolasHug but 2nd for loop in function test_rotate_fill requires nums_bands-list which depends upon modes-list. So we have to define modes-list inside the function even if we do parameterization. So is that okay as it is defeating the purpose of parameterization? |
Ah I missed that. If I understand the logic correctly here, we should be able to remove this last for loop and just hardcode Basically, |
PR Raised for Group B test_accimage_crop test_affine |
Hi, @NicolasHug I'd like to work on Group H. |
Hi, @NicolasHug I'd like to work on Group L. |
Hi all,I am working only on Group G,Group D please take initiate to raise PR for Group B,Group C |
@harishsdev no worries, I can send in a PR if you are not working on them anymore. |
Hi @AnirudhDagar are you working on both B and C? I can help with one. |
Sure @Ishan-Kumar2! I was about to start with B, but let me know the one you prefer. I'll take the other. :)) |
Okay @AnirudhDagar you can continue with B, I'll try C. |
All done! Thank you so much everyone for your help!! |
Currently, most tests in test/test_transforms.py rely on
unittest.TestCase
. Now that we supportpytest
, we want to remove the use of theunittest
module.For a similar issue see #3956
Instructions
There are many tests in this file, so I bundled them in multiple related groups below. If you're interested in working on this issue, please comment below with "I'm working on
<group X>
,<group Y>
, etc..." so that others don't pick the same tests as you do. Feel free to pick as many groups as you wish, but please don't submit more than 2 groups per PR in order to keep the reviews manageable. Before picking a group, make sure it wasn't picked by another contributor first. Thanks!!How to port a test to pytest
Porting a test from
unittest
to pytest is usually fairly straightforward. For a typical example, see https://github.com/pytorch/vision/pull/3907/files:Tester(unittest.TestCase)
class and just declare it as a function@unittest.skipIf
withpytest.mark.skipif(cond, reason=...)
self.assertXYZ
.assertEqual(a, b)
can be replaced byassert a == b
when a and b are pure python objects (scalars, tuples, lists), and otherwise we can rely onassert_equal
which is already used in the file.self.assertRaises
should be replaced with thepytest.raises(Exp, match=...):
context manager, as done in https://github.com/pytorch/vision/pull/3907/files. Same for warnings withpytest.warns
self.assertTrue
should be replaced with a plainassert
pytest.mark.parametrize
instead, as done e.g. in https://github.com/pytorch/vision/pull/3907/files.TestToPILImage
class, the tests in group N could be inTestPad
, etc. Not all groups need a dedicated class though, it's on a case-by-case basis.CC @ShrillShrestha and @zhiqwang in case you're interested in this too :)
Groups:
Groups A: Port Group A test_transforms.py to pytest #3959
test_1_channel_ndarray_to_pil_image
test_1_channel_tensor_to_pil_image
test_2_channel_ndarray_to_pil_image
test_2_channel_tensor_to_pil_image
test_2d_ndarray_to_pil_image
test_2d_tensor_to_pil_image
test_3_channel_ndarray_to_pil_image
test_3_channel_tensor_to_pil_image
test_4_channel_ndarray_to_pil_image
test_4_channel_tensor_to_pil_image
test_ndarray_bad_types_to_pil_image
test_tensor_bad_types_to_pil_image
Group B port test_accimage_xxx in test_transforms to pytest #3985
test_accimage_crop
test_accimage_pil_to_tensor
test_accimage_resize
test_accimage_to_tensor
Group C Port affine transform tests in test_tranforms to pytest #3984
test_affine
test_random_affine
Group D Group G,Group D #3981
test_autoaugment
test_center_crop
test_center_crop_2
test_color_jitter
Group E Group E test_transforms.py port to pytest #4026
test_convert_image_dtype_float_to_float
test_convert_image_dtype_float_to_int
test_convert_image_dtype_int_to_float
test_convert_image_dtype_int_to_int
test_convert_image_dtype_int_to_int_consistency
Group F Port to_tensor tests in test_transforms to pytest #3966
test_pil_to_tensor
test_to_tensor
test_to_tensor_with_other_default_dtypes
Group G Group G,Group D #3981
test_five_crop
test_ten_crop
test_max_value
test_linear_transformation
Group H Port group H test_transforms.py to pytest #3964
test_random_apply
test_random_choice
test_random_order
Group I Port some test_random_xxx in test_transforms to pytest #3972
test_random_crop
test_random_erasing
test_random_rotation
test_randomperspective
test_randomperspective_fill
Group J Port test resize in test_transforms to pytest #3952
test_randomresized_params
test_resize
Group K port tests in test_transforms to pytest #3957
test_rotate
test_rotate_fill
test_gaussian_blur_asserts
test_lambda
Group L Refactor test random horizontal flip #3971
test_random_horizontal_flip
test_random_vertical_flip
test_normalize
test_normalize_3d_tensor
test_normalize_different_dtype
Group M Port grayscale tests in test_tranforms to pytest #3962
test_to_grayscale
test_random_grayscale
Group N Port test pad in test_transforms to pytest #3954
test_pad
test_pad_raises_with_invalid_pad_sequence_len
test_pad_with_mode_F_images
test_pad_with_non_constant_padding_modes
test_pad_with_tuple_of_pad_values
Group O Port Group O test to pytest ref #3945 #3955
test_random_invert
test_random_posterize
test_random_solarize
test_random_adjust_sharpness
test_random_autocontrast
test_random_equalize
Group P port adjusts in test_transforms to pytest #3950
test_adjust_brightness
test_adjust_contrast
test_adjust_gamma
test_adjust_hue
test_adjust_saturation
test_adjust_sharpness
test_adjusts_L_mode
cc @pmeier
The text was updated successfully, but these errors were encountered: