summaryrefslogtreecommitdiff
path: root/numpy/core/multiarray.py
diff options
context:
space:
mode:
authordg3192 <113710955+dg3192@users.noreply.github.com>2022-09-26 04:16:06 -0700
committerGitHub <noreply@github.com>2022-09-26 13:16:06 +0200
commitcf2b314a4c5fb7bb05c1d265d2ba3e22bd859203 (patch)
treea666ec6622d8744c9d7155fa6aaf70af9327c9f4 /numpy/core/multiarray.py
parent561a9aae424b32cb85161b5f573997b03f3fe947 (diff)
downloadnumpy-cf2b314a4c5fb7bb05c1d265d2ba3e22bd859203.tar.gz
DOC: Add copyto example (#22292)
Diffstat (limited to 'numpy/core/multiarray.py')
-rw-r--r--numpy/core/multiarray.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py
index 2d0725e2f..d5f01a369 100644
--- a/numpy/core/multiarray.py
+++ b/numpy/core/multiarray.py
@@ -1107,6 +1107,22 @@ def copyto(dst, src, casting=None, where=None):
A boolean array which is broadcasted to match the dimensions
of `dst`, and selects elements to copy from `src` to `dst`
wherever it contains the value True.
+
+ Examples
+ --------
+ >>> A = np.array([4, 5, 6])
+ >>> B = [1, 2, 3]
+ >>> np.copyto(A, B)
+ >>> A
+ array([1, 2, 3])
+
+ >>> A = np.array([[1, 2, 3], [4, 5, 6]])
+ >>> B = [[4, 5, 6], [7, 8, 9]]
+ >>> np.copyto(A, B)
+ >>> A
+ array([[4, 5, 6],
+ [7, 8, 9]])
+
"""
return (dst, src, where)