numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
broadcast_arrays(*args, subok=False)

Parameters

`*args` : array_likes

The arrays to broadcast.

subok : bool, optional

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

Returns

broadcasted : list of arrays

These arrays are views on the original arrays. They are typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location. If you need to write to the arrays, make copies first. While you can set the writable flag True, writing to a single output value may end up changing more than one location in the output array.

deprecated

The output is currently marked so that if written to, a deprecation warning will be emitted. A future version will set the writable flag False so writing to it will raise an error.

Broadcast any number of arrays against each other.

See Also

broadcast
broadcast_shapes
broadcast_to

Examples

>>> x = np.array([[1,2,3]])
... y = np.array([[4],[5]])
... np.broadcast_arrays(x, y) [array([[1, 2, 3], [1, 2, 3]]), array([[4, 4, 4], [5, 5, 5]])]

Here is a useful idiom for getting contiguous copies instead of non-contiguous views.

>>> [np.array(a) for a in np.broadcast_arrays(x, y)]
[array([[1, 2, 3],
       [1, 2, 3]]), array([[4, 4, 4],
       [5, 5, 5]])]
See :

Back References

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

numpy.broadcast_to numpy.broadcast_shapes numpy.broadcast dask.array.core.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#479
type: <class 'function'>
Commit: