[NumPy-Tickets] [NumPy] #1845: The memory layout is wrong after sliced (was: Reading in pickled array slices gives a different memory structure than the one pickled out.)
NumPy Trac
numpy-tickets@scipy....
Sun Sep 11 15:21:39 CDT 2011
#1845: The memory layout is wrong after sliced
----------------------------+-----------------------------------------------
Reporter: ddev | Owner: somebody
Type: defect | Status: new
Priority: high | Milestone: Unscheduled
Component: numpy.core | Version: 1.6.0
Keywords: slice, strides |
----------------------------+-----------------------------------------------
Changes (by turncc):
* keywords: => slice, strides
* priority: normal => high
* component: Other => numpy.core
Comment:
It seems like a bug in the slicing algorithm.
If you do following:
{{{
import numpy as np
a = np.arange(5)
b = a[::2]
print 'strides of b:', b.data.strides
print 'bytes of b:', b.data.tobytes()
}}}
You will get:
{{{
strides of b: (8,)
bytes of b: b'\x02\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00'
}}}
Problem 1:
{{{
b's strides should be (4,) not (8,)
}}}
Problem 2:
{{{
The bytes of b should be
b'\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00'
not
b'\x02\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00'
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1845#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list