Test to check the shape of the ndarray

This commit is contained in:
Ankit Daftery 2011-06-14 03:32:10 +00:00
parent 0a76801936
commit 2794a9bd15
2 changed files with 27 additions and 0 deletions

View File

@ -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()

View File

@ -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);
}