MCPcopy Create free account
hub / github.com/ml-explore/mlx / test_init_from_array

Method test_init_from_array

python/tests/test_array.py:501–517  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

499 self.assertEqual(dfdx(x).item(), 2.0)
500
501 def test_init_from_array(self):
502 x = mx.array(3.0)
503 y = mx.array(x)
504
505 self.assertTrue(mx.array_equal(x, y))
506
507 y = mx.array(x, mx.int32)
508 self.assertEqual(y.dtype, mx.int32)
509 self.assertEqual(y.item(), 3)
510
511 y = mx.array(x, mx.bool_)
512 self.assertEqual(y.dtype, mx.bool_)
513 self.assertEqual(y.item(), True)
514
515 y = mx.array(x, mx.complex64)
516 self.assertEqual(y.dtype, mx.complex64)
517 self.assertEqual(y.item(), 3.0 + 0j)
518
519 def test_array_repr(self):
520 x = mx.array(True)

Callers

nothing calls this directly

Calls 2

itemMethod · 0.80
arrayMethod · 0.60

Tested by

no test coverage detected