Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63423 - in sandbox/numpy: boost/python/numpy libs/python/numpy/src
From: talljimbo_at_[hidden]
Date: 2010-06-29 03:55:35


Author: jbosch
Date: 2010-06-29 03:55:33 EDT (Tue, 29 Jun 2010)
New Revision: 63423
URL: http://svn.boost.org/trac/boost/changeset/63423

Log:
boost.python.numpy - added ndarray::reshape
Text files modified:
   sandbox/numpy/boost/python/numpy/ndarray.hpp | 3 +++
   sandbox/numpy/libs/python/numpy/src/ndarray.cpp | 8 ++++++++
   2 files changed, 11 insertions(+), 0 deletions(-)

Modified: sandbox/numpy/boost/python/numpy/ndarray.hpp
==============================================================================
--- sandbox/numpy/boost/python/numpy/ndarray.hpp (original)
+++ sandbox/numpy/boost/python/numpy/ndarray.hpp 2010-06-29 03:55:33 EDT (Tue, 29 Jun 2010)
@@ -115,6 +115,9 @@
     /// @brief Eliminate any unit-sized dimensions.
     ndarray squeeze() const;
 
+ /// @brief Equivalent to self.reshape(*shape) in Python.
+ ndarray reshape(tuple const & shape) const;
+
     /**
      * @brief If the array contains only a single element, return it as an array scalar; otherwise return
      * the array.

Modified: sandbox/numpy/libs/python/numpy/src/ndarray.cpp
==============================================================================
--- sandbox/numpy/libs/python/numpy/src/ndarray.cpp (original)
+++ sandbox/numpy/libs/python/numpy/src/ndarray.cpp 2010-06-29 03:55:33 EDT (Tue, 29 Jun 2010)
@@ -185,6 +185,14 @@
     );
 }
 
+ndarray ndarray::reshape(tuple const & shape) const {
+ return ndarray(
+ python::detail::new_reference(
+ PyArray_Reshape(reinterpret_cast<PyArrayObject*>(this->ptr()), shape.ptr())
+ )
+ );
+}
+
 object ndarray::scalarize() const {
     Py_INCREF(ptr());
     return object(python::detail::new_reference(PyArray_Return(reinterpret_cast<PyArrayObject*>(ptr()))));


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk