@@ -16,13 +16,13 @@ def test_make_grid_not_inplace(self):
16
16
t_clone = t .clone ()
17
17
18
18
utils .make_grid (t , normalize = False )
19
- assert torch .equal (t , t_clone ), 'make_grid modified tensor in-place'
19
+ self . assertTrue ( torch .equal (t , t_clone ), 'make_grid modified tensor in-place' )
20
20
21
21
utils .make_grid (t , normalize = True , scale_each = False )
22
- assert torch .equal (t , t_clone ), 'make_grid modified tensor in-place'
22
+ self . assertTrue ( torch .equal (t , t_clone ), 'make_grid modified tensor in-place' )
23
23
24
24
utils .make_grid (t , normalize = True , scale_each = True )
25
- assert torch .equal (t , t_clone ), 'make_grid modified tensor in-place'
25
+ self . assertTrue ( torch .equal (t , t_clone ), 'make_grid modified tensor in-place' )
26
26
27
27
def test_normalize_in_make_grid (self ):
28
28
t = torch .rand (5 , 3 , 10 , 10 ) * 255
@@ -38,22 +38,22 @@ def test_normalize_in_make_grid(self):
38
38
rounded_grid_max = torch .round (grid_max * 10 ** n_digits ) / (10 ** n_digits )
39
39
rounded_grid_min = torch .round (grid_min * 10 ** n_digits ) / (10 ** n_digits )
40
40
41
- assert torch .equal (norm_max , rounded_grid_max ), 'Normalized max is not equal to 1'
42
- assert torch .equal (norm_min , rounded_grid_min ), 'Normalized min is not equal to 0'
41
+ self . assertTrue ( torch .equal (norm_max , rounded_grid_max ), 'Normalized max is not equal to 1' )
42
+ self . assertTrue ( torch .equal (norm_min , rounded_grid_min ), 'Normalized min is not equal to 0' )
43
43
44
44
@unittest .skipIf ('win' in sys .platform , 'temporarily disabled on Windows' )
45
45
def test_save_image (self ):
46
46
with tempfile .NamedTemporaryFile (suffix = '.png' ) as f :
47
47
t = torch .rand (2 , 3 , 64 , 64 )
48
48
utils .save_image (t , f .name )
49
- assert os .path .exists (f .name ), 'The image is not present after save'
49
+ self . assertTrue ( os .path .exists (f .name ), 'The image is not present after save' )
50
50
51
51
@unittest .skipIf ('win' in sys .platform , 'temporarily disabled on Windows' )
52
52
def test_save_image_single_pixel (self ):
53
53
with tempfile .NamedTemporaryFile (suffix = '.png' ) as f :
54
54
t = torch .rand (1 , 3 , 1 , 1 )
55
55
utils .save_image (t , f .name )
56
- assert os .path .exists (f .name ), 'The pixel image is not present after save'
56
+ self . assertTrue ( os .path .exists (f .name ), 'The pixel image is not present after save' )
57
57
58
58
@unittest .skipIf ('win' in sys .platform , 'temporarily disabled on Windows' )
59
59
def test_save_image_file_object (self ):
@@ -64,7 +64,8 @@ def test_save_image_file_object(self):
64
64
fp = BytesIO ()
65
65
utils .save_image (t , fp , format = 'png' )
66
66
img_bytes = Image .open (fp )
67
- assert torch .equal (F .to_tensor (img_orig ), F .to_tensor (img_bytes )), 'Image not stored in file object'
67
+ self .assertTrue (torch .equal (F .to_tensor (img_orig ), F .to_tensor (img_bytes )),
68
+ 'Image not stored in file object' )
68
69
69
70
@unittest .skipIf ('win' in sys .platform , 'temporarily disabled on Windows' )
70
71
def test_save_image_single_pixel_file_object (self ):
@@ -75,7 +76,8 @@ def test_save_image_single_pixel_file_object(self):
75
76
fp = BytesIO ()
76
77
utils .save_image (t , fp , format = 'png' )
77
78
img_bytes = Image .open (fp )
78
- assert torch .equal (F .to_tensor (img_orig ), F .to_tensor (img_bytes )), 'Pixel Image not stored in file object'
79
+ self .assertTrue (torch .equal (F .to_tensor (img_orig ), F .to_tensor (img_bytes )),
80
+ 'Pixel Image not stored in file object' )
79
81
80
82
81
83
if __name__ == '__main__' :
0 commit comments