Use higher precision for linspace with double (#3029)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user