1 // Copyright Jim Bosch & Ankit Daftery 2010-2012. 2 // Copyright Stefan Seefeld 2016. 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 #include <boost/python/numpy.hpp> 8 9 namespace p = boost::python; 10 namespace np = boost::python::numpy; 11 reshape(np::ndarray old_array,p::tuple shape)12np::ndarray reshape(np::ndarray old_array, p::tuple shape) 13 { 14 np::ndarray local_shape = old_array.reshape(shape); 15 return local_shape; 16 } 17 BOOST_PYTHON_MODULE(shapes_ext)18BOOST_PYTHON_MODULE(shapes_ext) 19 { 20 np::initialize(); 21 p::def("reshape", reshape); 22 } 23