Commit 7ea33ca3 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2435 from gabrieldemarmiesse/test_memoryviews_7

Added tests for "typed memoryviews" part 7
parents 0366b382 60dcd089
from cython cimport view
# direct access in both dimensions, strided in the first dimension, contiguous in the last
cdef int[:, ::view.contiguous] a
# contiguous list of pointers to contiguous lists of ints
cdef int[::view.indirect_contiguous, ::1] b
# direct or indirect in the first dimension, direct in the second dimension
# strided in both dimensions
cdef int[::view.generic, :] c
from cython cimport view
# VALID
cdef int[::view.indirect, ::1, :] a
cdef int[::view.indirect, :, ::1] b
cdef int[::view.indirect_contiguous, ::1, :] c
...@@ -415,31 +415,21 @@ The flags are as follows: ...@@ -415,31 +415,21 @@ The flags are as follows:
* contiguous - contiguous and direct * contiguous - contiguous and direct
* indirect_contiguous - the list of pointers is contiguous * indirect_contiguous - the list of pointers is contiguous
and they can be used like this:: and they can be used like this:
from cython cimport view .. literalinclude:: ../../examples/userguide/memoryviews/memory_layout.pyx
# direct access in both dimensions, strided in the first dimension, contiguous in the last
cdef int[:, ::view.contiguous] a
# contiguous list of pointers to contiguous lists of ints Only the first, last or the dimension following an indirect dimension may be
cdef int[::view.indirect_contiguous, ::1] b specified contiguous:
# direct or indirect in the first dimension, direct in the second dimension .. literalinclude:: ../../examples/userguide/memoryviews/memory_layout_2.pyx
# strided in both dimensions
cdef int[::view.generic, :] c
Only the first, last or the dimension following an indirect dimension may be ::
specified contiguous::
# INVALID # INVALID
cdef int[::view.contiguous, ::view.indirect, :] a cdef int[::view.contiguous, ::view.indirect, :] d
cdef int[::1, ::view.indirect, :] b cdef int[::1, ::view.indirect, :] e
# VALID
cdef int[::view.indirect, ::1, :] a
cdef int[::view.indirect, :, ::1] b
cdef int[::view.indirect_contiguous, ::1, :]
The difference between the `contiguous` flag and the `::1` specifier is that the The difference between the `contiguous` flag and the `::1` specifier is that the
former specifies contiguity for only one dimension, whereas the latter specifies former specifies contiguity for only one dimension, whereas the latter specifies
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment