Skip to content

Commit

Permalink
Merge pull request #8064 from asi1024/scipy-linalg-zerosize
Browse files Browse the repository at this point in the history
Fix scipy.linalg not to raise DeprecationWarning for zero-size inputs
  • Loading branch information
takagi committed Jan 5, 2024
2 parents cc63966 + a7b6215 commit 1eb425a
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/cupyx_tests/scipy_tests/sparse_tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ def test_sparse(self, format, dtype, xp, sp):
M = sp.linalg.aslinearoperator(M)
return self._test_cg(dtype, xp, sp, a, M)

@testing.with_requires('scipy>1.11')
@testing.for_dtypes('fdFD')
@testing.numpy_cupy_allclose(rtol=1e-5, atol=1e-5, sp_name='sp')
def test_empty(self, dtype, xp, sp):
Expand All @@ -414,10 +415,7 @@ def test_empty(self, dtype, xp, sp):
a = xp.empty((0, 0), dtype=dtype)
b = xp.empty((0,), dtype=dtype)
if self.atol is None and xp == numpy:
# Note: If atol is None or not specified, Scipy (at least 1.5.3)
# raises DeprecationWarning
with pytest.deprecated_call():
return sp.linalg.cg(a, b)
return sp.linalg.cg(a, b)
else:
return sp.linalg.cg(a, b)

Expand Down Expand Up @@ -563,6 +561,7 @@ def test_sparse(self, format, dtype, xp, sp):
M = sp.linalg.aslinearoperator(M)
return self._test_gmres(dtype, xp, sp, a, M)

@testing.with_requires('scipy>1.11')
@testing.for_dtypes('fdFD')
@testing.numpy_cupy_allclose(rtol=1e-5, atol=1e-5, sp_name='sp')
def test_empty(self, dtype, xp, sp):
Expand All @@ -572,10 +571,7 @@ def test_empty(self, dtype, xp, sp):
a = xp.empty((0, 0), dtype=dtype)
b = xp.empty((0,), dtype=dtype)
if self.atol is None and xp == numpy:
# Note: If atol is None or not specified, Scipy (at least 1.5.3)
# raises DeprecationWarning
with pytest.deprecated_call():
return sp.linalg.gmres(a, b)
return sp.linalg.gmres(a, b)
else:
return sp.linalg.gmres(a, b)

Expand Down Expand Up @@ -1549,6 +1545,7 @@ def test_sparse(self, format, dtype, xp, sp):
M = sp.linalg.aslinearoperator(M)
return self._test_cgs(dtype, xp, sp, a, M)

@testing.with_requires('scipy>1.11')
@testing.for_dtypes('fdFD')
@testing.numpy_cupy_allclose(rtol=1e-5, atol=1e-5, sp_name='sp')
def test_empty(self, dtype, xp, sp):
Expand All @@ -1558,10 +1555,7 @@ def test_empty(self, dtype, xp, sp):
a = xp.empty((0, 0), dtype=dtype)
b = xp.empty((0,), dtype=dtype)
if self.atol is None and xp == numpy:
# Note: If atol is None or not specified, Scipy (at least 1.5.3)
# raises DeprecationWarning
with pytest.deprecated_call():
return sp.linalg.cgs(a, b)
return sp.linalg.cgs(a, b)
else:
return sp.linalg.cgs(a, b)

Expand Down

0 comments on commit 1eb425a

Please sign in to comment.