Skip to content

Commit cedca37

Browse files
zou3519facebook-github-bot
authored andcommittedNov 11, 2019
Re-enable TestNamedTensor.test_big_tensor_repr (pytorch#29407)
Summary: Pull Request resolved: pytorch#29407 Fixes pytorch#27753. The bug was that random tensors print subtly differently. This causes the "names=" tag to appear in slightly different places; sometimes it is on the same line as the data, sometimes it is on different lines. For this test, we wanted to know the following: - printing a big named tensor's repr doesn't crash - a big named tensor's repr shows the names This PR changes the test to check those two things. Test Plan: - run existing tests Differential Revision: D18428657 Pulled By: zou3519 fbshipit-source-id: 6bcf247ffba010520878a175e766a496028f87d9
1 parent b3b8f52 commit cedca37

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 

‎test/test_namedtensor.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,11 @@ def test_no_multiprocessing_support(self):
275275
with self.assertRaisesRegex(RuntimeError, "NYI"):
276276
ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(named_tensor)
277277

278-
@unittest.skip("Issue 27753")
279-
def test_big_tensor_repr(self):
278+
def test_big_tensor_repr_has_names(self):
280279
def check_repr(named_tensor):
281280
unnamed_tensor = named_tensor.rename(None)
282-
expected = "{}, names={})".format(repr(unnamed_tensor)[:-1], named_tensor.names)
283-
self.assertEqual(repr(named_tensor), expected)
281+
names_tag = 'names={}'.format(named_tensor.names)
282+
self.assertIn(names_tag, repr(named_tensor))
284283

285284
check_repr(torch.randn(128, 3, 64, 64, names=('N', 'C', 'H', 'W')))
286285

0 commit comments

Comments
 (0)
Please sign in to comment.