Unverified Commit 07729eb5 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

[FBcode->GH] Remove deprecated functional modules (#7953)


Co-authored-by: default avatarNicolas Hug <contact@nicolas-hug.com>
Co-authored-by: default avatarNicolas Hug <nh.nicolas.hug@gmail.com>
parent 7b4681a6
...@@ -2,7 +2,6 @@ import math ...@@ -2,7 +2,6 @@ import math
import os import os
import random import random
import re import re
import textwrap
from functools import partial from functools import partial
import numpy as np import numpy as np
...@@ -24,7 +23,7 @@ try: ...@@ -24,7 +23,7 @@ try:
except ImportError: except ImportError:
stats = None stats = None
from common_utils import assert_equal, assert_run_python_script, cycle_over, float_dtypes, int_dtypes from common_utils import assert_equal, cycle_over, float_dtypes, int_dtypes
GRACE_HOPPER = get_file_path_2( GRACE_HOPPER = get_file_path_2(
...@@ -2241,35 +2240,5 @@ def test_random_grayscale_with_grayscale_input(): ...@@ -2241,35 +2240,5 @@ def test_random_grayscale_with_grayscale_input():
torch.testing.assert_close(F.pil_to_tensor(output_pil), image_tensor) torch.testing.assert_close(F.pil_to_tensor(output_pil), image_tensor)
# TODO: remove in 0.17 when we can delete functional_pil.py and functional_tensor.py
@pytest.mark.parametrize(
"import_statement",
(
"from torchvision.transforms import functional_pil",
"from torchvision.transforms import functional_tensor",
"from torchvision.transforms.functional_tensor import resize",
"from torchvision.transforms.functional_pil import resize",
),
)
@pytest.mark.parametrize("from_private", (True, False))
def test_functional_deprecation_warning(import_statement, from_private):
if from_private:
import_statement = import_statement.replace("functional", "_functional")
source = f"""
import warnings
with warnings.catch_warnings():
warnings.simplefilter("error")
{import_statement}
"""
else:
source = f"""
import pytest
with pytest.warns(UserWarning, match="removed in 0.17"):
{import_statement}
"""
assert_run_python_script(textwrap.dedent(source))
if __name__ == "__main__": if __name__ == "__main__":
pytest.main([__file__]) pytest.main([__file__])
import warnings
from torchvision.transforms._functional_pil import * # noqa
warnings.warn(
"The torchvision.transforms.functional_pil module is deprecated "
"in 0.15 and will be **removed in 0.17**. Please don't rely on it. "
"You probably just need to use APIs in "
"torchvision.transforms.functional or in "
"torchvision.transforms.v2.functional."
)
import warnings
from torchvision.transforms._functional_tensor import * # noqa
warnings.warn(
"The torchvision.transforms.functional_tensor module is deprecated "
"in 0.15 and will be **removed in 0.17**. Please don't rely on it. "
"You probably just need to use APIs in "
"torchvision.transforms.functional or in "
"torchvision.transforms.v2.functional."
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment