[Numpy-tickets] [NumPy] #1030: C function PyArray_New seems to ignore the 'strides' argument.

NumPy numpy-tickets@scipy....
Fri Feb 27 04:04:10 CST 2009

#1030: C function PyArray_New seems to ignore the 'strides' argument.
 Reporter:  alexis.roche  |       Owner:  somebody
     Type:  defect        |      Status:  new     
 Priority:  highest       |   Milestone:  1.3.0   
Component:  Other         |     Version:  none    
 Severity:  normal        |    Keywords:          
 I create the following two arrays as follows:

 X = np.asarray([[0,1,2],[3,4,5]]).astype('uint8')
 x = X[:, 0] ## x == array([0, 3])

 I then pass X to a C routine that attempts to create another view on
 X[:,0] using:

 npy_intp dim[1] = {2};
 npy_intp strides[1] = {3};
 int itemsize = 1;
 PyArrayObject* y = (PyArrayObject*) PyArray_New(&PyArray_Type, 1, dim,
 type, strides,
 itemsize, NPY_CARRAY, NULL);

 While I expect y to be equal to x, the result is array([ 0,  1]), which
 would have been the expected result if I had set the 'strides' argument to
 1. I am running numpy version 1.3.0.dev6468.

 I have been using PyArray_New for 3 years in similar context with devel
 versions of numpy, and only caught that weird behavior recently.

Ticket URL: <http://scipy.org/scipy/numpy/ticket/1030>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.

More information about the Numpy-tickets mailing list