numpy / numpy/numpy

ENH: Named ellipsis in einsum

Open
#22,860 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

01 - Enhancement
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Proposed new feature or change:

Proposed new feature or change:

In the subsripts of einsum, allow ellipsis replaced by a named star notation like '(*i)', which can be explicitly referenced and expanded after '->'.

Example
import numpy as np

a = np.zeros((2, 3, 4))

assert np.einsum('(*i)k,(*j)k->(*i)(*j)', a, a).shape == (2, 3, 2, 3)
assert np.einsum('(*i)k,(*i)k->(*i)', a, a).shape == (2, 3)

Alternative

Omit parentheses

import numpy as np

a = np.zeros((2, 3))

assert np.einsum('*ik,*jk->*i*j', a, a).shape == (2, 3, 2, 3)
assert np.einsum('*ik,*ik->*i', a, a).shape == (2, 3)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the numpy.einsum entry point and run the two proposed examples to compare the named-star and alternative syntaxes. Done means the requested ellipsis notation can be explicitly referenced and expanded after ->, producing the example output shapes.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.