2
2
import itertools
3
3
import math
4
4
import os
5
+ import re
5
6
from typing import Sequence
6
7
7
8
import numpy as np
23
24
)
24
25
from torchvision .transforms import InterpolationMode
25
26
26
-
27
27
NEAREST , BILINEAR , BICUBIC = InterpolationMode .NEAREST , InterpolationMode .BILINEAR , InterpolationMode .BICUBIC
28
28
29
29
@@ -141,7 +141,13 @@ def test_rotate_batch(self, device, dt):
141
141
def test_rotate_deprecation_resample (self ):
142
142
tensor , _ = _create_data (26 , 26 )
143
143
# assert deprecation warning and non-BC
144
- with pytest .warns (UserWarning , match = r"Argument resample is deprecated and will be removed" ):
144
+ with pytest .warns (
145
+ UserWarning ,
146
+ match = re .escape (
147
+ "The parameter 'resample' is deprecated since 0.12 and will be removed 0.14. "
148
+ "Please use 'interpolation' instead."
149
+ ),
150
+ ):
145
151
res1 = F .rotate (tensor , 45 , resample = 2 )
146
152
res2 = F .rotate (tensor , 45 , interpolation = BILINEAR )
147
153
assert_equal (res1 , res2 )
@@ -365,7 +371,13 @@ def test_warnings(self, device):
365
371
tensor , pil_img = _create_data (26 , 26 , device = device )
366
372
367
373
# assert deprecation warning and non-BC
368
- with pytest .warns (UserWarning , match = r"Argument resample is deprecated and will be removed" ):
374
+ with pytest .warns (
375
+ UserWarning ,
376
+ match = re .escape (
377
+ "The parameter 'resample' is deprecated since 0.12 and will be removed in 0.14. "
378
+ "Please use 'interpolation' instead."
379
+ ),
380
+ ):
369
381
res1 = F .affine (tensor , 45 , translate = [0 , 0 ], scale = 1.0 , shear = [0.0 , 0.0 ], resample = 2 )
370
382
res2 = F .affine (tensor , 45 , translate = [0 , 0 ], scale = 1.0 , shear = [0.0 , 0.0 ], interpolation = BILINEAR )
371
383
assert_equal (res1 , res2 )
@@ -376,7 +388,13 @@ def test_warnings(self, device):
376
388
res2 = F .affine (tensor , 45 , translate = [0 , 0 ], scale = 1.0 , shear = [0.0 , 0.0 ], interpolation = BILINEAR )
377
389
assert_equal (res1 , res2 )
378
390
379
- with pytest .warns (UserWarning , match = r"Argument fillcolor is deprecated and will be removed" ):
391
+ with pytest .warns (
392
+ UserWarning ,
393
+ match = re .escape (
394
+ "The parameter 'fillcolor' is deprecated since 0.12 and will be removed in 0.14. "
395
+ "Please use 'fill' instead."
396
+ ),
397
+ ):
380
398
res1 = F .affine (pil_img , 45 , translate = [0 , 0 ], scale = 1.0 , shear = [0.0 , 0.0 ], fillcolor = 10 )
381
399
res2 = F .affine (pil_img , 45 , translate = [0 , 0 ], scale = 1.0 , shear = [0.0 , 0.0 ], fill = 10 )
382
400
# we convert the PIL images to numpy as assert_equal doesn't work on PIL images.
0 commit comments