dask.array.broadcast_arrays — Dask documentation (original) (raw)
Broadcast any number of arrays against each other.
This docstring was copied from numpy.broadcast_arrays.
Some inconsistencies with the Dask version may exist.
import numpy as np
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]])]