[Numpy-discussion] Programmatically contracting multiple tensors

Michael Lamparski diagonaldevice at gmail.com
Wed Mar 24 20:57:17 EDT 2021

Hi, I must thank y'all for the exceptionally fast responses (and apologize
for my own tragically slow response!)

On Sat, Mar 13, 2021 at 1:32 AM Eric Wieser <wieser.eric+numpy at gmail.com>
> Einsum has a secret integer argument format that appears in the Examples
section of the
> `np.einsum` docs, but appears not to be mentioned at all in the parameter

Ah, yes, this is precisely the sort of API I was hoping for!  I found it
pretty easy to use, but here's a snippet that solves my original problem
for those wondering:


On Fri, Mar 12, 2021 at 8:09 PM Andras Deak <deak.andris at gmail.com> wrote:
> But I'm not sure _where_ this could be highlighted among the
> parameters; after all this is all covered by the *operands parameter.

The parameter list is definitely one of the places I checked most
closely, and having something there would have helped.  I'd say that,
technically, this also overlaps with the subscripts argument, which now
holds the first array, and I feel like that may be the best place to put
something.  For instance, a short paragraph could be added to the end of

"einsum also has an alternative interface that uses integer labels for
axes, in which case the subscripts argument is not present.  This is
documented below." (with a link)

(the idea I'm trying to capture here is to avoid creating any specific (or
potentially wrong) picture of how the arguments look in the alternate
signature, more or less forcing the reader to follow a link to where it is
more easily described somewhere outside the constraints of parameter-based

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/numpy-discussion/attachments/20210324/49d045cc/attachment.html>

More information about the NumPy-Discussion mailing list