2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-25 06:22:15 +00:00

ndarray.shape(k),strides(k) act more like their python counterparts (negative indexing, bounds checking) (issue #157)

This commit is contained in:
Mark Borgerding
2017-09-20 09:39:46 -04:00
committed by Stefan Seefeld
parent 00b7ed03a7
commit ecf05c4a90
4 changed files with 66 additions and 4 deletions

View File

@@ -31,6 +31,9 @@ np::ndarray transpose(np::ndarray arr) { return arr.transpose();}
np::ndarray squeeze(np::ndarray arr) { return arr.squeeze();}
np::ndarray reshape(np::ndarray arr,p::tuple tup) { return arr.reshape(tup);}
Py_intptr_t shape_index(np::ndarray arr,int k) { return arr.shape(k); }
Py_intptr_t strides_index(np::ndarray arr,int k) { return arr.strides(k); }
BOOST_PYTHON_MODULE(ndarray_ext)
{
np::initialize();
@@ -43,4 +46,6 @@ BOOST_PYTHON_MODULE(ndarray_ext)
p::def("transpose", transpose);
p::def("squeeze", squeeze);
p::def("reshape", reshape);
p::def("shape_index", shape_index);
p::def("strides_index", strides_index);
}