[NumPy-Tickets] [NumPy] #1599: as_strided arrays are not reshape-able
NumPy Trac
numpy-tickets@scipy....
Wed Sep 1 13:49:07 CDT 2010
#1599: as_strided arrays are not reshape-able
--------------------------------+-------------------------------------------
Reporter: dalleyg | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.5.0
Component: numpy.core | Version: 1.4.0rc1
Keywords: as_strided reshape |
--------------------------------+-------------------------------------------
Arrays created by as_strided are not reshape-able. If one attempts to
reshape, the operation will appear to succeed, but corrupted data will
result.
Here's a test example.
{{{
import numpy;
print numpy.__version__;
xx = numpy.arange(3, dtype=int)[None, None, :];
xx2 = numpy.lib.stride_tricks.as_strided(xx, shape=(2,1,3),
strides=xx.strides);
xx3=xx2.reshape((2,3));
print xx3
}}}
It prints things like
{{{
[[ 0 1 2]
[5602136 33 0]]
}}}
Note that the second row should look like the first, but it doesn't.
This issue exists in numpy 1.3.0 and numpy 1.4.1 (at least). I do not
know if it persists in numpy 1.5.0.
IMHO, reshape should: be generalized to handle restrided arrays (at least
ones that are restrided to perform a cheap tile operation), copy the array
if the strides are too nonstandard, and/or raise an exception if the
strides are too nonstandard.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1599>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list