FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

BUG: return 0 from empty object np.vdot by bigjokker · Pull Request #32310 · numpy/numpy · GitHub

/ numpy Public

BUG: return 0 from empty object np.vdot - #32310

Closed
bigjokker wants to merge 2 commits into
numpy:mainfrom
bigjokker:bug-vdot-empty-object
Closed

BUG: return 0 from empty object np.vdot#32310
bigjokker wants to merge 2 commits into
numpy:mainfrom
bigjokker:bug-vdot-empty-object

Conversation

Copy link
Copy Markdown

Description

np.vdot of a zero-length object array returned None instead of a zero-like result. OBJECT_vdot never wrote an identity value when n == 0, so the output pointer stayed NULL and PyArray_Return turned that into None.

This is the same empty-product case that np.vecdot hit in gh-31019. The fix matches gh-31033: store 0 when the contracted axis has length 0.

vdot flattens, so all of these now return the scalar 0:

>>> import numpy as np
>>> np.vdot(np.empty((0,), dtype=object), np.empty((0,), dtype=object))
0
>>> np.vdot(np.empty((1, 0), dtype=object), np.empty((1, 0), dtype=object))
0

Fixes #31735

OBJECT_vdot left the output as NULL when n == 0, which
PyArray_Return turned into None. Use the same empty-product
zero as OBJECT_dotc (numpygh-31033).

Fixes numpy#31735

Copy link
Copy Markdown
Member

You ignored the PR template, so I'm going to assume that this PR has been made with agentic AI. This violates our AI policy; we prefer to talk to humans.

jorenham closed this Aug 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: vdot of object arrays along zero-length is None

2 participants


Back | FazBrowse Home | New Git URL