bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / broadcast_to
_ArrayFunctionDispatcher
numpy:broadcast_to
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/lib/_stride_tricks_impl.py :400
Signature
def broadcast_to ( array , shape , subok = False ) Summary
Broadcast an array to a new shape.
Parameters
array: array_likeThe array to broadcast.
shape: tuple or intThe shape of the desired array. A single integer
iis interpreted as(i,).subok: bool, optionalIf True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).
Returns
broadcast: arrayA readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.
Raises
: ValueErrorIf the array is not compatible with the new shape according to NumPy's broadcasting rules.
Examples
import numpy as np x = np.array([1, 2, 3]) np.broadcast_to(x, (3, 3))✓
See also
- broadcast
- broadcast_arrays
- broadcast_shapes
Aliases
-
numpy.broadcast_to