Commit 45a6cb0f authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Moved a copy memoryview example to the examples directory.

parent 084a25f5
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
...@@ -125,17 +125,9 @@ means you get consecutive slices for every unspecified dimension:: ...@@ -125,17 +125,9 @@ means you get consecutive slices for every unspecified dimension::
Copying Copying
------- -------
Memory views can be copied in place:: Memory views can be copied in place:
cdef int[:, :, :] to_view, from_view .. literalinclude:: ../../examples/userguide/memoryviews/copy.pyx
...
# copy the elements in from_view to to_view
to_view[...] = from_view
# or
to_view[:] = from_view
# or
to_view[:, :, :] = from_view
They can also be copied with the ``copy()`` and ``copy_fortran()`` methods; see They can also be copied with the ``copy()`` and ``copy_fortran()`` methods; see
:ref:`view_copy_c_fortran`. :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