Skip to content

BUG: Matrix multiplication of a coo_matrix with an invalid type value does not raise a TypeErrorΒ #22347

@asi1024

Description

@asi1024

Describe your issue.

In SciPy 1.15, matrix multiplication of a coo_matrix with an invalid type value does not raise a TypeError. This is a minor bug that will not cause major confusion, but it is likely not the intended behavior.

Reproducing Code Example

In SciPy 1.15.1,

>>> import scipy
>>> x = scipy.sparse.coo_matrix((3, 4))
>>> x.dot(None)
NotImplemented

In SciPy 1.14.1 (Expected),

>>> import scipy
>>> x = scipy.sparse.coo_matrix((3, 4))
>>> x.dot(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../.pyenv/versions/3.11.11/lib/python3.11/site-packages/scipy/sparse/_base.py", line 450, in dot
    return self @ other
           ~~~~~^~~~~~~
TypeError: unsupported operand type(s) for @: 'coo_matrix' and 'NoneType'

SciPy/NumPy/Python version and system information

OS             : Linux-5.4.0-193-generic-x86_64-with-glibc2.31
Python Version : 3.11.11
NumPy Version  : 2.2.1
SciPy Version  : 1.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.sparse

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions