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

Method test_array_namespace_asarray

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

Source from the content-addressed store, hash-verified

2112 self.assertTrue(hasattr(api, "add"))
2113
2114 def test_array_namespace_asarray(self):
2115 xp = mx.array(1.0).__array_namespace__()
2116 self.assertTrue(hasattr(xp, "asarray"))
2117
2118 arr = xp.asarray([1, 2, 3])
2119 self.assertEqual(arr.tolist(), [1, 2, 3])
2120
2121 arr_f32 = xp.asarray([1, 2, 3], dtype=mx.float32)
2122 self.assertEqual(arr_f32.dtype, mx.float32)
2123
2124 existing = mx.array([4, 5, 6])
2125 arr_pass = xp.asarray(existing)
2126 self.assertEqual(arr_pass.tolist(), [4, 5, 6])
2127
2128 def test_asarray(self):
2129 # List inputs

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.60

Tested by

no test coverage detected