Skip to content

BUG: np.dot does not behave well with sparse vectors #30198

@FelixBenning

Description

@FelixBenning

Describe the issue:

In the numpy docs about np.dot it is explained:

If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).

However this does not seem to be the case for scipy sparse arrays.

Reproduce the code example:

>>> import numpy as np
>>> from scipy import sparse

>>> basis = sparse.eye_array(3, format="csr")
>>> v, w = basis[0], basis[1]

>>> np.dot(v,w).shape
(3,)

>>> np.dot(v.todense(), w.todense()).shape()
()

Error message:

Python and NumPy Versions:

Numpy version: 2.3.4
Python version: 3.13.7 (main, Aug 14 2025, 11:12:11) [Clang 17.0.0 (clang-1700.0.13.3)]

Runtime Environment:

No response

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bug57 - Close?Issues which may be closable unless discussion continued

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions