GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: np.einsum() fails with a 0-dimensional out argument and optimize='optimal' by krivenko · Pull Request #31354 · numpy/numpy

Conversation

@krivenko

@krivenko krivenko commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@krivenko
BUG: np.einsum() fails with a 0-dimensional out argument and optimize…
b774b11
…='optimal'
seberg
seberg approved these changes Apr 28, 2026
View reviewed changes

@seberg seberg left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, small nit, but I think it is also good as is.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread numpy/_core/tests/test_einsum.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seberg seberg added 00 - Bug 09 - Backport-Candidate PRs tagged should be backported labels Apr 28, 2026
@krivenko @seberg
Update numpy/_core/tests/test_einsum.py
5ea7e7c
Co-authored-by: Sebastian Berg <[email protected]>
@krivenko
krivenko force-pushed the einsum-0d-out-optimize branch from d108479 to 5ea7e7c Compare April 28, 2026 14:15
@krivenko

krivenko commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

@seberg There was a missing : in the change you suggested, so I had to amend that commit...

seberg reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

seberg
seberg reviewed Apr 28, 2026
View reviewed changes
Comment thread numpy/_core/tests/test_einsum.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seberg
Apply suggestions from code review
5625e7e
Co-authored-by: Sebastian Berg <[email protected]>
@seberg

seberg commented Apr 28, 2026

Copy link
Copy Markdown
Member

Thanks @krivenko, nice little fix!

krivenko reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seberg
seberg merged commit 425f631 into numpy:main Apr 28, 2026
83 of 84 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@charris charris mentioned this pull request Apr 28, 2026
BUG: np.einsum() fails with a 0-dimensional out argument and optimize='optimal' (#31354) #31358
Merged
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Apr 28, 2026
@krivenko
krivenko deleted the einsum-0d-out-optimize branch April 28, 2026 19:09
charris pushed a commit that referenced this pull request Apr 28, 2026
@krivenko @seberg @charris
BUG: np.einsum() fails with a 0-dimensional out argument and optimize…
083c575
…='optimal' (#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 <[email protected]>
charris added a commit that referenced this pull request Apr 28, 2026
@charris
Merge pull request #31358 from charris/backport-31354
f7b4af7
BUG: np.einsum() fails with a 0-dimensional out argument and optimize='optimal' (#31354)
MaanasArora pushed a commit to MaanasArora/numpy that referenced this pull request May 7, 2026
@krivenko @seberg @MaanasArora
BUG: np.einsum() fails with a 0-dimensional out argument and optimize…
ac6ec3a
…='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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@seberg seberg seberg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

00 - Bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@krivenko @seberg @charris
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.