Skip to content
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 #3958

Closed
wants to merge 8 commits into from
Closed

Port test/test_transforms #3958

wants to merge 8 commits into from

Conversation

harishsdev
Copy link
Contributor

@harishsdev harishsdev commented Jun 3, 2021

PR for below porting pytest code

Group B

test_accimage_crop
test_accimage_pil_to_tensor
test_accimage_resize
test_accimage_to_tensor
Group C

test_affine
test_random_affine

@harishsdev
Copy link
Contributor Author

PR for #3945

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @harishsdev ! I just made a quick pass

@@ -681,15 +681,224 @@ def test_convert_image_dtype_int_to_int_consistency(self):
self.assertEqual(actual_min, desired_min)
self.assertEqual(actual_max, desired_max)

@unittest.skipIf(accimage is None, 'accimage not available')

def test_affine(self):
Copy link
Member

Choose a reason for hiding this comment

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

We should try to move these methods out of the class and just have pure functions at the bottom of the file. In the code below there are a lot of references to self which we want to remove and replace as per the instrucitons in #3945 :)

Comment on lines 688 to 690
for pt in [(16, 16), (20, 16), (20, 20)]:
for i in range(-5, 5):
for j in range(-5, 5):
Copy link
Member

Choose a reason for hiding this comment

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

these 3 for-loops is typically the kind of thing that we will want to parametrize, as done for example in https://github.com/pytorch/vision/pull/3907/files

@harishsdev harishsdev closed this Jun 5, 2021
@harishsdev
Copy link
Contributor Author

I will open NEW PR as i am facing many issues for PEP8

@NicolasHug
Copy link
Member

@harishsdev thanks for your work so far. It's usually better to just stick to a single PR: opening many PRs makes it harder for us to keep track of the changes and of the reviews. It's totally fine to push many fix commit in a given PR: we'll squash them all when merging anyway so all commits will disappear.

Comment on lines +34 to +35
with pytest.raises(ValueError):
transforms.RandomAffine(-0.7)
Copy link
Member

Choose a reason for hiding this comment

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

We'll need 1 raises block per line here, because we need to make sure that each individual line raises a ValueError. That's not your fault: the original code was wrong I think


def test_random_affine():
Copy link
Member

Choose a reason for hiding this comment

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

Please write these new tests at the end of the file instead of at the beginning, it will be easier to find the remaining tests that need to be ported :)

@pytest.mark.parametrize(i,range(-5,5))
@pytest.mark.parametrize(j,range(-5,5))

def test_affine('a','t1','s','s',i,j):
Copy link
Member

Choose a reason for hiding this comment

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

this should be a, t1, s, etc., without the quotes as they're parameter names

@pytest.mark.parametrize('t1',range(-10, 10, 5))
@pytest.mark.parametrize('s',[0.77, 1.0, 1.27])
@pytest.mark.parametrize('s1',range(-15, 15, 5))
@pytest.mark.parametrize(pt,[(16, 16), (20, 16), (20, 20)])
Copy link
Member

Choose a reason for hiding this comment

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

this should be 'pt' with quotes and you'll need a space after the comma ;)

(here and in other places)

@harishsdev
Copy link
Contributor Author

okay,Thanks @NicolasHug ,please help to reopen this PR

@NicolasHug
Copy link
Member

Unfortunately it seems that you deleted your fork (or your branch?) so I can't reopen.

That's fine, we can open a new PR, but please make sure to take a look at my comments above :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants