[Numpy-discussion] einsum
Mark Wiebe
mwwiebe at gmail.com
Wed Jan 26 22:54:15 EST 2011
On Wed, Jan 26, 2011 at 6:41 PM, Jonathan Rocher <jrocher at enthought.com>wrote:
> Nice function, and wonderful that it speeds some tasks up.
>
> some feedback: the following notation is a little counter intuitive to me:
> >>> np.einsum('i...->', a)
> array([50, 55, 60, 65, 70])
> >>> np.sum(a, axis=0)
> array([50, 55, 60, 65, 70])
> Since there is nothing after the ->, I expected a scalar not a vector. I
> might suggest 'i...->...'
>
Hmm, the dimension that's left is a a broadcast dimension, and the dimension
labeled 'i' did go away. I suppose disallowing the empty output string and
forcing a '...' is reasonable. Would disallowing broadcasting by default be
a good approach? Then,
einsum('ii->i', a) would only except two dimensional inputs, and you would
have to specify einsum('...ii->...i', a) to get the current default behavior
for it.
Just noticed also a typo in the doc:
>
> order : 'C', 'F', 'A', or 'K'
> Controls the memory layout of the output. 'C' means it should
> be Fortran contiguous. 'F' means it should be Fortran contiguous,
> should be changed to
> order : 'C', 'F', 'A', or 'K'
> Controls the memory layout of the output. 'C' means it should
> be C contiguous. 'F' means it should be Fortran contiguous,
>
>
Thanks,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110126/1bcd3e54/attachment.html>
More information about the NumPy-Discussion
mailing list