bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / _core / _multiarray_umath / copyto
built-in
numpy._core._multiarray_umath:copyto
Signature
copyto ( dst , src , casting = same_kind , where = True ) Summary
Copies values from one array to another, broadcasting as necessary.
Extended Summary
Raises a TypeError if the casting rule is violated, and if where is provided, it selects which elements to copy.
Parameters
dst: ndarrayThe array into which values are copied.
src: array_likeThe array from which values are copied.
casting: {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optionalControls what kind of data casting may occur when copying.
'no' means the data types should not be cast at all.
'equiv' means only byte-order changes are allowed.
'safe' means only casts which can preserve values are allowed.
'same_kind' means only safe casts or casts within a kind, like float64 to float32, are allowed.
'unsafe' means any data conversions may be done.
where: array_like of bool, optionalA boolean array which is broadcasted to match the dimensions of
dst, and selects elements to copy fromsrctodstwherever it contains the value True.
Examples
import numpy as np A = np.array([4, 5, 6]) B = [1, 2, 3] np.copyto(A, B) A
A = np.array([[1, 2, 3], [4, 5, 6]]) B = [[4, 5, 6], [7, 8, 9]] np.copyto(A, B) A
Aliases
-
numpy._core._multiarray_umath.copyto