mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-05 07:34:42 +08:00
* Nicer exceptions for ops on non-arrays
This commit is contained in:

committed by
GitHub

parent
3fc993f82d
commit
0caf35f4b8
@@ -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):
|
||||
|
Reference in New Issue
Block a user