mirror of
https://github.com/boostorg/python.git
synced 2026-01-24 06:02:14 +00:00
Fix ndarray tests.
This commit is contained in:
@@ -16,6 +16,7 @@ test-suite numpy
|
||||
|
||||
[ numpy-test templates ]
|
||||
[ numpy-test ufunc ]
|
||||
[ numpy-test shapes ]
|
||||
[ numpy-test shapes ]
|
||||
[ numpy-test ndarray ]
|
||||
|
||||
;
|
||||
|
||||
@@ -34,11 +34,11 @@ class TestNdarray(unittest.TestCase):
|
||||
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()
|
||||
|
||||
@@ -18,10 +18,14 @@ bp::numpy::ndarray empty1(bp::tuple shape, bp::numpy::dtype dt) {
|
||||
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 @@ BOOST_PYTHON_MODULE(ndarray_mod) {
|
||||
bp::def("array",&array2);
|
||||
bp::def("array",&array1);
|
||||
bp::def("empty",&empty1);
|
||||
bp::def("empty",&c_empty);
|
||||
bp::def("c_empty",&c_empty);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user