mirror of
https://github.com/ml-explore/mlx.git
synced 2025-11-01 16:58:08 +08:00
real and imag properties (#2189)
This commit is contained in:
@@ -2022,6 +2022,15 @@ class TestArray(mlx_tests.MLXTestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
mx.add(y, x)
|
||||
|
||||
def test_real_imag(self):
|
||||
x = mx.array([1.0])
|
||||
self.assertEqual(x.real.item(), 1.0)
|
||||
self.assertEqual(x.imag.item(), 0.0)
|
||||
|
||||
x = mx.array([1.0 + 1.0j])
|
||||
self.assertEqual(x.imag.item(), 1.0)
|
||||
self.assertEqual(x.real.item(), 1.0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user