Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72687 - sandbox/numpy/libs/python/numpy/test
From: seefeld_at_[hidden]
Date: 2011-06-19 16:08:49


Author: stefan
Date: 2011-06-19 16:08:48 EDT (Sun, 19 Jun 2011)
New Revision: 72687
URL: http://svn.boost.org/trac/boost/changeset/72687

Log:
Fix ndarray tests.
Text files modified:
   sandbox/numpy/libs/python/numpy/test/Jamfile | 3 ++-
   sandbox/numpy/libs/python/numpy/test/ndarray.py | 10 +++++-----
   sandbox/numpy/libs/python/numpy/test/ndarray_mod.cpp | 14 +++++++++-----
   3 files changed, 16 insertions(+), 11 deletions(-)

Modified: sandbox/numpy/libs/python/numpy/test/Jamfile
==============================================================================
--- sandbox/numpy/libs/python/numpy/test/Jamfile (original)
+++ sandbox/numpy/libs/python/numpy/test/Jamfile 2011-06-19 16:08:48 EDT (Sun, 19 Jun 2011)
@@ -16,6 +16,7 @@
 
     [ numpy-test templates ]
     [ numpy-test ufunc ]
- [ numpy-test shapes ]
+ [ numpy-test shapes ]
+ [ numpy-test ndarray ]
 
   ;

Modified: sandbox/numpy/libs/python/numpy/test/ndarray.py
==============================================================================
--- sandbox/numpy/libs/python/numpy/test/ndarray.py (original)
+++ sandbox/numpy/libs/python/numpy/test/ndarray.py 2011-06-19 16:08:48 EDT (Sun, 19 Jun 2011)
@@ -34,11 +34,11 @@
                         dt = numpy.dtype(dtp)
                         for shape in ((60,),(6,10),(4,3,5),(2,2,3,5)):
                                 a1 = ndarray_mod.empty(shape,dt)
- a2 = ndarray_mod.empty(len(shape),shape,dt)
- self.assert_(shape,a1.shape)
- self.assert_(type(a1),dtp)
- self.assert_(shape,a2.shape)
- self.assert_(dt,type(a2))
+ a2 = ndarray_mod.c_empty(shape,dt)
+ self.assertEqual(shape,a1.shape)
+ #self.assert_(type(a1),dtp)
+ self.assertEqual(shape,a2.shape)
+ #self.assert_(dtp,type(a2))
 
 if __name__=="__main__":
         unittest.main()

Modified: sandbox/numpy/libs/python/numpy/test/ndarray_mod.cpp
==============================================================================
--- sandbox/numpy/libs/python/numpy/test/ndarray_mod.cpp (original)
+++ sandbox/numpy/libs/python/numpy/test/ndarray_mod.cpp 2011-06-19 16:08:48 EDT (Sun, 19 Jun 2011)
@@ -18,10 +18,14 @@
         return bp::numpy::empty(shape,dt);
 }
 
-bp::numpy::ndarray c_empty(int nd,bp::tuple shape, bp::numpy::dtype dt) {
- bp::tuple c_tup = bp::make_tuple(shape);
- Py_intptr_t* c_shape = bp::extract<Py_intptr_t *>(c_tup);
- return bp::numpy::empty(nd,c_shape,dt);
+bp::numpy::ndarray c_empty(bp::tuple shape, bp::numpy::dtype dt) {
+ // convert 'shape' to a C array so we can test the corresponding
+ // version of the constructor
+ unsigned len = bp::len(shape);
+ Py_intptr_t *c_shape = new Py_intptr_t[len];
+ for (unsigned i = 0; i != len; ++i)
+ c_shape[i] = bp::extract<Py_intptr_t>(shape[i]);
+ return bp::numpy::empty(len, c_shape, dt);
 }
 
 BOOST_PYTHON_MODULE(ndarray_mod) {
@@ -30,5 +34,5 @@
         bp::def("array",&array2);
         bp::def("array",&array1);
         bp::def("empty",&empty1);
- bp::def("empty",&c_empty);
+ bp::def("c_empty",&c_empty);
 }


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