weird shape for memory view

41 views
Skip to first unread message

Hai Nguyen

unread,
Apr 16, 2015, 5:32:39 PM4/16/15
to cython-users
Hi all,

I have been using cython memory view for my projects and so far it's terrific. 

However I still don't understand about the shape of the memory view. Please see the example below

from cpython.array cimport array as pyarray
from cpython cimport array

cdef int w=100, h=100
cdef pyarray arr0 = array.clone(pyarray('d', []), w*h, zero=True)
cdef double[:] myview_0 = arr0
cdef double[:, :] myview_1 = <double[:w, :h]> &myview_0[0]

print (myview_1.shape)

I was expecting to get shape=(100, 100) but I got [100, 100, 0, 0, 0, 0, 0, 0]

info:
python 2 (and 3), cython 0.22pre (and 0.22), Windows (and Linux too).

Did I miss anything?
thanks

Hai

Matthias Kümmerer

unread,
Nov 23, 2015, 4:00:04 PM11/23/15
to cython-users
I can reproduce this behaviour on debian testing, with system python (2.7.10+), system numpy and system cython (0.23.2) as well as the newest cython from pip (0.23.4). The wrong shapes appear using g++4.8 and g++-5.2. The same code produces correct shapes in ubuntu 14.04.

Matthias Kümmerer

unread,
Nov 23, 2015, 4:00:04 PM11/23/15
to cython-users
sorry, I have to correct myself: In Ubuntu14.04 I also get the weird shapes. I couldn't reproduce another segfault that might be related to this in ubuntu, but I have to investigate this further.


Am Donnerstag, 16. April 2015 17:32:39 UTC-4 schrieb Hai Nguyen:
Reply all
Reply to author
Forward
0 new messages