Skip to content

Commit

Permalink
Fixed some linter issues pt1
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHeeHee committed Apr 29, 2024
1 parent 9b70967 commit 0f96771
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/dynamo/test_same_allclose.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@
class TestSameAllclose(unittest.TestCase):
def test_same_allclose_exception(self):
ref = torch.tensor([1.0, 2.0, 3.0])
res = torch.tensor([1.0, 2.0, float('nan')])
res = torch.tensor([1.0, 2.0, float("nan")])

try:
same(ref, res, equal_nan=False)
except RuntimeError as e:
self.assertIn("An unexpected error occurred while comparing tensors with torch.allclose", str(e))
self.assertIn("RuntimeError: The size of tensor a (3) must match the size of tensor b (3) at non-singleton dimension 0", str(e))
self.assertIn(
"An unexpected error occurred while comparing tensors with torch.allclose",
str(e),
)
self.assertIn(
"RuntimeError: The size of tensor a (3) must match the size of tensor b (3) "
"at non-singleton dimension 0",
str(e),
)
else:
self.fail("RuntimeError not raised")

Expand All @@ -21,5 +28,5 @@ def test_same_allclose_no_exception(self):

self.assertTrue(same(ref, res))

if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

0 comments on commit 0f96771

Please sign in to comment.