Test to check the shape of the ndarray
This commit is contained in:
parent
0a76801936
commit
2794a9bd15
14
libs/python/numpy/test/shapes.py
Normal file
14
libs/python/numpy/test/shapes.py
Normal 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()
|
13
libs/python/numpy/test/shapes_mod.cpp
Normal file
13
libs/python/numpy/test/shapes_mod.cpp
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user