class `numpy.``broadcast`[source]

Produce an object that mimics broadcasting.

Parameters: in1, in2, … : array_like Input parameters. b : broadcast object Broadcast the input parameters against one another, and return an object that encapsulates the result. Amongst others, it has `shape` and `nd` properties, and may be used as an iterator.

Examples

```>>> x = np.array([, , ])
>>> y = np.array([4, 5, 6])
```
```>>> out = np.empty(b.shape)
>>> out.flat = [u+v for (u,v) in b]
>>> out
array([[ 5.,  6.,  7.],
[ 6.,  7.,  8.],
[ 7.,  8.,  9.]])
```

```>>> x + y
array([[5, 6, 7],
[6, 7, 8],
[7, 8, 9]])
```
Attributes: `index` current index in broadcasted result `iters` tuple of iterators along `self`’s “components.” nd Number of dimensions of broadcasted result. For code intended for NumPy 1.12.0 and later the more consistent `ndim` is preferred. ```>>> x = np.array([1, 2, 3]) >>> y = np.array([, , ]) >>> b = np.broadcast(x, y) >>> b.nd 2 ``` ndim Number of dimensions of broadcasted result. Alias for `nd`. New in version 1.12.0. ```>>> x = np.array([1, 2, 3]) >>> y = np.array([, , ]) >>> b = np.broadcast(x, y) >>> b.ndim 2 ``` numiter Number of iterators possessed by the broadcasted result. ```>>> x = np.array([1, 2, 3]) >>> y = np.array([, , ]) >>> b = np.broadcast(x, y) >>> b.numiter 2 ``` `shape` Shape of broadcasted result. `size` Total size of broadcasted result.

Methods

 `reset`() Reset the broadcasted result’s iterator(s).

#### Previous topic

numpy.ndenumerate.next