Better exceptions in case of invalid operations on mlx.core.array (#910) (#926)

* Nicer exceptions for ops on non-arrays
This commit is contained in:
AmirHossein_Razlighi
2024-04-03 07:41:24 +03:30
committed by GitHub
parent 3fc993f82d
commit 0caf35f4b8
4 changed files with 132 additions and 1 deletions

View File

@@ -203,6 +203,29 @@ class TestInequality(mlx_tests.MLXTestCase):
with self.assertRaises(ValueError):
a >= tpl_
def test_invalid_op_on_array(self):
str_ = "hello"
a = mx.array([1, 2.5, 3.25])
lst_ = [1, 2.1, 3.25]
tpl_ = (1, 2.5, 3.25)
with self.assertRaises(ValueError):
a * str_
with self.assertRaises(ValueError):
a *= str_
with self.assertRaises(ValueError):
a /= lst_
with self.assertRaises(ValueError):
a // lst_
with self.assertRaises(ValueError):
a % lst_
with self.assertRaises(ValueError):
a**tpl_
with self.assertRaises(ValueError):
a & tpl_
with self.assertRaises(ValueError):
a | str_
class TestArray(mlx_tests.MLXTestCase):
def test_array_basics(self):