Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72576 - sandbox/numpy/libs/python/numpy/test
From: ankitdaf_at_[hidden]
Date: 2011-06-13 23:32:11


Author: ankitdaf
Date: 2011-06-13 23:32:10 EDT (Mon, 13 Jun 2011)
New Revision: 72576
URL: http://svn.boost.org/trac/boost/changeset/72576

Log:
Test to check the shape of the ndarray
Added:
   sandbox/numpy/libs/python/numpy/test/shapes.py (contents, props changed)
   sandbox/numpy/libs/python/numpy/test/shapes_mod.cpp (contents, props changed)

Added: sandbox/numpy/libs/python/numpy/test/shapes.py
==============================================================================
--- (empty file)
+++ sandbox/numpy/libs/python/numpy/test/shapes.py 2011-06-13 23:32:10 EDT (Mon, 13 Jun 2011)
@@ -0,0 +1,14 @@
+import shapes_mod
+import unittest
+import numpy
+
+class TestShapes(unittest.TestCase):
+
+ def testShapes(self):
+ a1 = numpy.array([(0,1),(2,3)])
+ a1_shape = (1,4)
+ a1 = shapes_mod.reshape(a1,a1_shape)
+ self.assertEqual(a1_shape,a1.shape)
+
+if __name__=="__main__":
+ unittest.main()

Added: sandbox/numpy/libs/python/numpy/test/shapes_mod.cpp
==============================================================================
--- (empty file)
+++ sandbox/numpy/libs/python/numpy/test/shapes_mod.cpp 2011-06-13 23:32:10 EDT (Mon, 13 Jun 2011)
@@ -0,0 +1,13 @@
+#include <boost/python/numpy.hpp>
+
+namespace bp = boost::python;
+
+bp::numpy::ndarray reshape(bp::numpy::ndarray old_array, bp::tuple shape) {
+ bp::numpy::ndarray local_shape = old_array.reshape(shape);
+ return local_shape;
+}
+
+BOOST_PYTHON_MODULE(shapes_mod) {
+ bp::numpy::initialize();
+ bp::def("reshape", &reshape);
+}


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