mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Remove a use of exec (#35624)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/35624 Python 2 has reached end-of-life and is no longer supported by PyTorch. This test case is valid syntax in Python 3. Test Plan: CI Differential Revision: D20842877 Pulled By: dreiss fbshipit-source-id: 856e72171496aa1d517f2f27a8a5066462cf4f76
This commit is contained in:
parent
7f7fdb1013
commit
2f4da7c00c
|
|
@ -162,12 +162,9 @@ class TestNamedTensor(TestCase):
|
||||||
self.assertTrue(fully_named.has_names())
|
self.assertTrue(fully_named.has_names())
|
||||||
|
|
||||||
def test_py3_ellipsis(self):
|
def test_py3_ellipsis(self):
|
||||||
# Need to exec or else flake8 will complain about invalid python 2.
|
|
||||||
tensor = torch.randn(2, 3, 5, 7)
|
tensor = torch.randn(2, 3, 5, 7)
|
||||||
scope = {'tensor': tensor}
|
output = tensor.refine_names('N', ..., 'C')
|
||||||
code_str = "output = tensor.refine_names('N', ..., 'C')"
|
self.assertEqual(output.names, ['N', None, None, 'C'])
|
||||||
exec(code_str, globals(), scope)
|
|
||||||
self.assertEqual(scope['output'].names, ['N', None, None, 'C'])
|
|
||||||
|
|
||||||
def test_refine_names(self):
|
def test_refine_names(self):
|
||||||
# Unnamed tensor -> Unnamed tensor
|
# Unnamed tensor -> Unnamed tensor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user