[Numpy-discussion] Is this a bug?

Charles R Harris charlesr.harris at gmail.com
Tue Sep 16 15:39:01 EDT 2014


On Tue, Sep 16, 2014 at 1:27 PM, Charles R Harris <charlesr.harris at gmail.com
> wrote:

> Hi All,
>
> It turns out that gufuncs will broadcast the last dimension if it is one.
> For instance, inner1d has signature `(n), (n) -> ()`, yet
>
> In [27]: inner1d([1,1,1], [1])
> Out[27]: 3
>
> In [28]: inner1d([1,1,1], [1,1])
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-28-e53e62e35349> in <module>()
> ----> 1 inner1d([1,1,1], [1,1])
>
> ValueError: inner1d: Operand 1 has a mismatch in its core dimension 0,
> with gufunc signature (i),(i)->() (size 2 is different from 3)
>
>
> I'd think this is a bug, as the dimensions should match. Note that scalar
> 1 will be promoted to [1] in this case.
>
> Thoughts?
>
>
This also holds for matrix_multiply

In [33]: matrix_multiply(eye(3), [[1]])
Out[33]:
array([[ 1.],
       [ 1.],
       [ 1.]])

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140916/a8f4c2d5/attachment.html>


More information about the NumPy-Discussion mailing list