Wed Aug 5 13:51:25 CDT 2009
On Wed, Aug 5, 2009 at 13:48, David Goldsmith<firstname.lastname@example.org> wrote:
> 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([, , ])
>>>> b = np.broadcast(x, y)
>>>> b.nd # returns what I'd expect
>>>> b = np.broadcast(x, y, x, y)
>>>> b.nd # doesn't return what I'd expect
Why don't you expect this? It's the correct answer. (x*y*x*y).shape == (3,3).
>>>> 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)
>>>> z = x * y # grasping at straws now
> array([[ 4, 8, 12],
> [ 5, 10, 15],
> [ 6, 12, 18]])
Yup. z.shape == (3,3). Broadcasting that with a (3,1) array or a (3,)
array still gives a (3,3) array.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Scipy-dev