Skip to content

BUG: np.einsum() fails with a 0-dimensional out argument and optimize='optimal' (#31354)#31358

Merged
charris merged 1 commit into
numpy:maintenance/2.4.xfrom
charris:backport-31354
Apr 28, 2026
Merged

BUG: np.einsum() fails with a 0-dimensional out argument and optimize='optimal' (#31354)#31358
charris merged 1 commit into
numpy:maintenance/2.4.xfrom
charris:backport-31354

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Apr 28, 2026

Backport of #31354.

PR summary

This PR fixes #31350.

It replaces the expression out[:] found in bmm_einsum() with the more universal out[...], which is also valid for a 0-dimensional out.

TestEinsum.test_einsum_misc() in numpy/_core/tests/test_einsum.py has been extended to cover #31350.

First time committer introduction

I am a researcher who uses NumPy in a multitude of scientific computing projects, mostly simulation codes for computational condensed matter theory. I discovered the issue #31350 while working on one of such (private) projects.

AI Disclosure

No AI has been used in preparation of this PR.

…='optimal' (numpy#31354)

It replaces the expression out[:] found in bmm_einsum() with the more universal out[...], which is also valid for a 0-dimensional out.
TestEinsum.test_einsum_misc() in numpy/_core/tests/test_einsum.py has been extended.

Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Apr 28, 2026
@charris charris added this to the 2.4.5 release milestone Apr 28, 2026
@charris
Copy link
Copy Markdown
Member Author

charris commented Apr 28, 2026

Blas failures are unrelated.

@charris charris merged commit f7b4af7 into numpy:maintenance/2.4.x Apr 28, 2026
74 of 76 checks passed
@charris charris deleted the backport-31354 branch April 28, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

00 - Bug 08 - Backport Used to tag backport PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants