Skip to content

BUG: 0th power of sparse array/matrix always returns the identity of float64 #15224

@takagi

Description

@takagi

Describe your issue.

The power of sparse array/matrix is expected to return one with the same dtype. However, in SciPy 1.8.0rc1, its 0th power always returns the identity of float64. I guess it was unintentionally missing in c3e4ec5.

Reproducing Code Example

>>> import numpy as np
>>> import scipy.sparse as sp
>>> a = sp.coo_array(np.ones((2, 2), dtype='D'))
>>> a.dtype
dtype('complex128')
>>> (a**0).dtype
dtype('float64')

Error message

N/A

SciPy/NumPy/Python version information

1.8.0rc1 1.22.0rc1 sys.version_info(major=3, minor=9, micro=7, releaselevel='final', serial=0)

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