Iterator for broadcasting

The general concept of broadcasting is also available from Python using the broadcast iterator. This object takes N objects as inputs and returns an iterator that returns tuples providing each of the input sequence elements in the broadcasted result.

>>> for val in broadcast([[1,0], [2,3]], [0,1]): . . . print val

(1,

0)

(0,

1)

(2,

0)

(3,

1)

The methods and attributes of the broadcast object are:

nd the number of dimensions in the broadcasted result.

shape the shape of the broadcasted result.

size the total size of the broadcasted result.

index the current (flat) index into the broadcasted array iters a tuple of (broadcasted) NumPy.flatiter objects, one for each array.

Reset the multiter object to the beginning. next ()

Get the next tuple of objects from the (broadcasted) arrays

0 0

Post a comment