numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
broadcast_to(array, shape, subok=False)

Notes

versionadded

Parameters

array : array_like

The array to broadcast.

shape : tuple or int

The shape of the desired array. A single integer i is interpreted as (i,) .

subok : bool, optional

If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).

Raises

ValueError

If the array is not compatible with the new shape according to NumPy's broadcasting rules.

Returns

broadcast : array

A 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.

Broadcast an array to a new shape.

See Also

broadcast
broadcast_arrays
broadcast_shapes

Examples

>>> x = np.array([1, 2, 3])
... np.broadcast_to(x, (3, 3)) array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.broadcast_shapes numpy.lib.stride_tricks.sliding_window_view numpy.lib.stride_tricks.as_strided numpy.broadcast numpy.tile dask.array.core.broadcast_to numpy.broadcast_arrays

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/lib/stride_tricks.py#366
type: <class 'function'>
Commit: