numpy / numpy/numpy

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

Open
#31,735 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the issue:

Following the bug discussed in #31019 for vecdot, np.vdot appears to show similar behavior for zero-length object arrays: it returns None instead of a zero-like scalar result.

For comparison, with the dtype=float, the result is 0.0.

Reproduce the code example:
import numpy as np

cases = [
    np.empty((0,), dtype=object),
    np.empty((1,0), dtype=object),
    np.empty((0,1), dtype=object),
    np.empty((0,0), dtype=object),
]

for x in cases:
    print(x.shape, np.vdot(x, x))
Error message:
Output: 

(0,) None
(1, 0) None
(0, 1) None
(0, 0) None
Python and NumPy Versions:

2.6.0.dev0+git20260623.4357ad1
3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0]

How does this issue affect you or how did you find it:

This issue was identified by an automated testing tool currently being developed by our research team.
Before reporting it, we reviewed the code, documentation and checked the latest development version of Numpy to confirm this observation.

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

Run the supplied examples against the current NumPy development version and trace the np.vdot entry point, using the related vecdot bug (#31019) as context. Check the zero-length object-array path and add regression coverage for the four shapes; done means vdot returns a zero-like scalar rather than None, consistent with the float case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.