int() and float() for mx.array (#1360)

This commit is contained in:
Alex Barron
2024-08-25 20:41:44 -07:00
committed by GitHub
parent 8081df79be
commit d1183821a7
3 changed files with 21 additions and 0 deletions
+2
View File
@@ -840,6 +840,8 @@ void init_array(nb::module_& m) {
},
"other"_a,
nb::rv_policy::none)
.def("__int__", [](array& a) { return nb::int_(to_scalar(a)); })
.def("__float__", [](array& a) { return nb::float_(to_scalar(a)); })
.def(
"flatten",
[](const array& a,