The following works: ``` %%cython cimport cython import numpy as np cimport numpy as np
def f(double[:,:] arr): cdef double[:] res = np.zeros(2*arr.size, dtype=np.float64) cdef double[:] tmp tmp = <double[:arr.size]>&arr[0,0] res[:arr.size] = tmp return res ``` whereas the following: ``` %%cython cimport cython import numpy as np cimport numpy as np def f(double[:,:] arr): cdef double[:] res = np.zeros(2*arr.size, dtype=np.float64) res[:arr.size] = <double[:arr.size]>&arr[0,0] return res ``` ...gives the below error: Error compiling Cython file: ------------------------------------------------------------ ... import numpy as np cimport numpy as np def f(double[:,:] arr): cdef double[:] res = np.zeros(2*arr.size, dtype=np.float64) res[:arr.size] = <double[:arr.size]>&arr[0,0] ^ ------------------------------------------------------------ d3ce.pyx:7:21: Cannot assign type 'double[::1]' to 'double' It would be nice if cython could take care of the temporary itself though the workaround is certainly simple enough that it's not a big issue at all. Thanks, Dave _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel