shapes.cpp 570 B

12345678910111213141516171819202122
  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. #include <boost/python/numpy.hpp>
  7. namespace p = boost::python;
  8. namespace np = boost::python::numpy;
  9. np::ndarray reshape(np::ndarray old_array, p::tuple shape)
  10. {
  11. np::ndarray local_shape = old_array.reshape(shape);
  12. return local_shape;
  13. }
  14. BOOST_PYTHON_MODULE(shapes_ext)
  15. {
  16. np::initialize();
  17. p::def("reshape", reshape);
  18. }