Use higher precision for linspace with double (#3029)

This commit is contained in:
Awni Hannun
2026-01-21 06:20:50 -08:00
committed by GitHub
parent 9a277a277a
commit 1d56dfdf59
3 changed files with 17 additions and 4 deletions
+2
View File
@@ -259,6 +259,8 @@ nb::object tolist(mx::array& a) {
return to_list<float>(a, 0, 0);
case mx::bfloat16:
return to_list<mx::bfloat16_t, float>(a, 0, 0);
case mx::float64:
return to_list<double>(a, 0, 0);
case mx::complex64:
return to_list<std::complex<float>>(a, 0, 0);
default:
+9
View File
@@ -292,6 +292,15 @@ class TestDouble(mlx_tests.MLXTestCase):
b = np.array(a)
self.assertTrue(np.array_equal(a, b))
a = mx.array([1.0, 2.0], mx.float64)
b = a.tolist()
self.assertEqual(b, [1.0, 2.0])
def test_linspace(self):
with mx.stream(mx.cpu):
vals = mx.linspace(0, math.pi, 2, mx.float64)
self.assertEqual(vals.tolist()[1], math.pi)
if __name__ == "__main__":
mlx_tests.MLXTestRunner()