From cf2b314a4c5fb7bb05c1d265d2ba3e22bd859203 Mon Sep 17 00:00:00 2001 From: dg3192 <113710955+dg3192@users.noreply.github.com> Date: Mon, 26 Sep 2022 04:16:06 -0700 Subject: DOC: Add copyto example (#22292) --- numpy/core/multiarray.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'numpy/core/multiarray.py') 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) -- cgit v1.2.1