@@ -81,6 +81,10 @@ NB_MODULE(_genmetaballs_bindings, m) {
8181 utils.def (" sigmoid" , sigmoid, nb::arg (" x" ), " Compute the sigmoid function: 1 / (1 + exp(-x))" );
8282
8383 nb::class_<Array2D<float >>(utils, " FloatArray2D" )
84+ .def_static (" from_array" ,
85+ [](const nb::ndarray<float , nb::ndim<2 >, nb::c_contig>& array) {
86+ return Array2D<float >(array.data (), array.shape (0 ), array.shape (1 ));
87+ })
8488 // TODO: switch to the array_api in future nanobind release
8589 // https://nanobind.readthedocs.io/en/latest/api_extra.html#_CPPv4N8nanobind9array_apiE
8690 .def (
@@ -90,10 +94,6 @@ NB_MODULE(_genmetaballs_bindings, m) {
9094 self.data (), {self.num_rows (), self.num_cols ()});
9195 },
9296 nb::rv_policy::reference_internal)
93- .def_static (" from_array" ,
94- [](const nb::ndarray<float , nb::ndim<2 >, nb::c_contig>& array) {
95- return Array2D<float >(array.data (), array.shape (0 ), array.shape (1 ));
96- })
9797 .def_prop_ro (" num_rows" , &Array2D<float >::num_rows)
9898 .def_prop_ro (" num_cols" , &Array2D<float >::num_cols)
9999 .def_prop_ro (" ndim" , &Array2D<float >::ndim)
0 commit comments