add E275 missing-whitespace-after-keyword linting rule (#6149)

requires space after keywords like `assert`, `not`, `return`, `else`
This commit is contained in:
chenyu
2024-08-17 16:44:34 -04:00
committed by GitHub
parent da4fa77e92
commit f7950fc2b6
7 changed files with 21 additions and 20 deletions

View File

@@ -13,25 +13,25 @@ class TestGC(unittest.TestCase):
a = Tensor.rand(4, 4, requires_grad=True)
b = Tensor.zeros(4, 4, requires_grad=True)
(a*b).mean().backward()
assert(tensors_allocated() > 0)
assert (tensors_allocated() > 0)
del a,b
assert(tensors_allocated() == 1) # one for Tensor._rng_counter
assert (tensors_allocated() == 1) # one for Tensor._rng_counter
def test_gc_complex(self):
a = Tensor(np.zeros((4, 4), dtype=np.float32), requires_grad=True)
b = Tensor.rand(4, 4, requires_grad=True)
assert(tensors_allocated() == 3)
assert (tensors_allocated() == 3)
(a*b).mean().backward()
assert(tensors_allocated() == 5)
assert (tensors_allocated() == 5)
del b
assert(tensors_allocated() == 3)
assert (tensors_allocated() == 3)
b = Tensor(np.zeros((4, 4), dtype=np.float32), requires_grad=True)
print(tensors_allocated())
(a*b).mean().backward()
print(tensors_allocated())
assert(tensors_allocated() == 5)
assert (tensors_allocated() == 5)
del b
assert(tensors_allocated() == 3)
assert (tensors_allocated() == 3)
if __name__ == '__main__':
unittest.main()