Describe your issue.
Found while porting over CuPy to support 1.18, one of the tests passes both out= and dtype=. It appears that in some cases, SciPy (since gh-24496) fails to return the out identity.
So basically mostly an inconvenience to track down why the test is failing (and now work around it).
I admit it is a rather odd to pass both dtype= and out=, but preserving strict out identity is maybe a nice simple fix anyway.
Reproducing Code Example
import numpy as np
import scipy
import scipy.sparse as sp
print("scipy", scipy.__version__, "numpy", np.__version__)
a = np.array([[0.0, 1.0], [2.0, 0.0]], dtype=np.float32)
A = sp.csr_array(a)
out = np.empty(2)
# Both dtype and `out` (yes, this is nonsense that `dtype=` is smaller than out...)
assert A.sum(axis=0, out=out, dtype=np.float32) is out
If you apply it along axis=, things pass.
Error message
`out` identity return isn't preserved (and a fresh array of dtype `dtype=dtype` returned instead).
SciPy/NumPy/Python version and system information
1.18 and current main. NumPy is irrelevant.
Describe your issue.
Found while porting over CuPy to support 1.18, one of the tests passes both
out=anddtype=. It appears that in some cases, SciPy (since gh-24496) fails to return theoutidentity.So basically mostly an inconvenience to track down why the test is failing (and now work around it).
I admit it is a rather odd to pass both
dtype=andout=, but preserving strict out identity is maybe a nice simple fix anyway.Reproducing Code Example
If you apply it along
axis=, things pass.Error message
SciPy/NumPy/Python version and system information