Assigning a NumPy array with a zero length dimension to a memoryview fails
if the memoryview is declared contiguous in the zero-length dimension.  I'm
getting a run-time error that the buffer is not C-contiguous or Fortran
contiguous.

See examples below.

Thanks,
Josh Ayers


cdef float [:, :] arr1 = numpy.empty((2, 0), 'f4') # works
cdef float [:, :] arr2 = numpy.empty((0, 2), 'f4') # works
cdef float [:, ::1] arr3 = numpy.empty((2, 0), 'f4') # fails (buffer not
C-contiguous)
cdef float [:, ::1] arr4 = numpy.empty((0, 2), 'f4') # works

cdef float [:, :] arr5 = numpy.empty((2, 0), 'f4', order='F') # works
cdef float [:, :] arr6 = numpy.empty((0, 2), 'f4', order='F') # works
cdef float [::1, :] arr7 = numpy.empty((2, 0), 'f4', order='F') # works
cdef float [::1, :] arr8 = numpy.empty((0, 2), 'f4', order='F') # fails
(buffer not Fortran contiguous)
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to