[SciPy-dev] numpy.broadcast

David Goldsmith d_l_goldsmith@yahoo....
Wed Aug 5 13:48:42 CDT 2009


I guess I don't really understand this too well - is the below correct behavior, and if so, why?

>>> x = np.array([1, 2, 3])
>>> y = np.array([[4], [5], [6]])
>>> b = np.broadcast(x, y)
>>> b.nd # returns what I'd expect
2
>>> b = np.broadcast(x, y, x, y)
>>> b.nd # doesn't return what I'd expect
2
>>> del b # maybe problem is that I have to "clear" b first?
>>> # or maybe it's that all args have to be different?
...
>>> b = np.broadcast(x, y, x * y)
>>> b.nd
2
>>> z = x * y # grasping at straws now
>>> z
array([[ 4,  8, 12],
       [ 5, 10, 15],
       [ 6, 12, 18]])
>>> x
array([1, 2, 3])
>>> y
array([[4],
       [5],
       [6]])
>>> del b # trying everything to get intuitive behavior
>>> b = np.broadcast(x, y, z)
>>> b.nd
2

Huhn?

DG


      


More information about the Scipy-dev mailing list