[SciPy-dev] numpy.broadcast
David Goldsmith
d_l_goldsmith at yahoo.com
Wed Aug 5 16:40:01 EDT 2009
--- On Wed, 8/5/09, David Goldsmith <d_l_goldsmith at yahoo.com> wrote:
> > It is necessarily == D. Broadcasting is associative.
> > The
> > (x*y*z).shape
> > == (x*(y*z)).shape == ((x*y)*z).shape.
Um:
>>> x = np.array((1, 2, 3))
>>> y = np.array([[4], [5], [6]])
>>> z = x * y
>>> x; y; z
array([1, 2, 3])
array([[4],
[5],
[6]])
array([[ 4, 8, 12],
[ 5, 10, 15],
[ 6, 12, 18]])
>>> B = np.broadcast
>>> X = B(x, y, z)
>>> Y = B(x, B(y, z))
>>> Z = B(B(x, y), z)
>>> X.numiter, Y.numiter, Z.numiter
(3, 2, 2)
>>> X.nd, Y.nd, Z.nd
(2, 1, 2)
>>> X.shape, Y.shape, Z.shape
((3, 3), (3,), (3, 3))
Am I doing something wrong?
DG
More information about the SciPy-Dev
mailing list