mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
ban __bool__ on Tensor (#3632)
* ban __bool__ on Tensor avoid misuse * test case * fix tests * fix more tests
This commit is contained in:
@@ -326,6 +326,14 @@ class TestTinygrad(unittest.TestCase):
|
||||
assert type(reshaped_item) == type(a), a
|
||||
np.testing.assert_allclose(reshaped_item, a), a
|
||||
|
||||
def test_no_bool(self):
|
||||
with self.assertRaises(TypeError):
|
||||
if Tensor(["3"]):
|
||||
print("hi")
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
_a = Tensor([3]) in [Tensor([3]), Tensor([4]), Tensor([5])]
|
||||
|
||||
@unittest.skipIf(CI and Device.DEFAULT in {"GPU", "CUDA", "METAL"}, "no GPU CI")
|
||||
class TestMoveTensor(unittest.TestCase):
|
||||
d0, d1 = f"{Device.DEFAULT}:0", f"{Device.DEFAULT}:1"
|
||||
|
||||
Reference in New Issue
Block a user