Commit 86d0c959 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2431 from gabrieldemarmiesse/test_memoryviews_4

Added tests for "typed memoryviews" part 4
parents 6a3fc36c 45a6cb0f
import numpy as np
cdef int[:, :, :] to_view, from_view
to_view = np.empty((20, 15, 30), dtype=np.intc)
from_view = np.ones((20, 15, 30), dtype=np.intc)
# copy the elements in from_view to to_view
to_view[...] = from_view
# or
to_view[:] = from_view
# or
to_view[:, :, :] = from_view
......@@ -117,17 +117,9 @@ means you get consecutive slices for every unspecified dimension::
Copying
-------
Memory views can be copied in place::
Memory views can be copied in place:
cdef int[:, :, :] to_view, from_view
...
# copy the elements in from_view to to_view
to_view[...] = from_view
# or
to_view[:] = from_view
# or
to_view[:, :, :] = from_view
.. literalinclude:: ../../examples/userguide/memoryviews/copy.pyx
They can also be copied with the ``copy()`` and ``copy_fortran()`` methods; see
:ref:`view_copy_c_fortran`.
......
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