[Numpy-discussion] Ransom Proposals
Tim Hochberg
tim.hochberg at cox.net
Mon Mar 27 09:51:04 CST 2006
Travis Oliphant wrote:
> Sasha wrote:
>
>> I never said that. What I said was x.reshape(shape) returns x itself
>> if shape==x.shape and a view othrwise.
>
> Is this true? I just checked on it and it didn't seem to be the
> case. Perhaps this was "fixed" during the recent reshape bug-fix.
>
It looks like the bug is in PyArray_Ravel. array_reshape calls
PyArray_Ravel if the newshape has dimension-1 (line 77 of array_methods.c):
if (newshape.len == 1) {
PyDimMem_FREE(newshape.ptr);
return PyArray_Ravel(self, 0);
}
Ravel in turn, returns self if the array is already flat (line 187 of
multiarray_module.c):
if (!fortran && PyArray_ISCONTIGUOUS(a)) {
if (a->nd == 1) {
Py_INCREF(a);
return (PyObject *)a;
}
return PyArray_Newshape(a, &newdim, PyArray_CORDER);
}
It looks like ripping out the second if statement would fix everything,
but I haven't tried it yet.
-tim
More information about the Numpy-discussion
mailing list