From 18724e80f1e507ae9ba0675eb2fc5df0104ec3db Mon Sep 17 00:00:00 2001 From: emcastillo Date: Thu, 2 Dec 2021 13:49:55 +0900 Subject: [PATCH] Merge pull request #6171 from leofang/add_signal_tests Add tests for `convolve2d` --- .../signal_tests/test_signaltools.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/cupyx_tests/scipy_tests/signal_tests/test_signaltools.py b/tests/cupyx_tests/scipy_tests/signal_tests/test_signaltools.py index 5ca4c0e2614..aa6dac740d9 100644 --- a/tests/cupyx_tests/scipy_tests/signal_tests/test_signaltools.py +++ b/tests/cupyx_tests/scipy_tests/signal_tests/test_signaltools.py @@ -209,6 +209,38 @@ def test_correlate2d(self, xp, scp, dtype): return self._filter('correlate2d', dtype, xp, scp) +@testing.with_requires('scipy') +class TestConvolve2DEdgeCase: + + @testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-5, scipy_name='scp') + def test_convolve2d_1(self, xp, scp): + # see cupy/cupy#5989 + from scipy import misc + ascent = misc.ascent() + if xp is cupy: + ascent = xp.asarray(ascent) + scharr = xp.array( + [[-3-3j, 0-10j, +3-3j], + [-10+0j, 0+0j, +10+0j], + [-3+3j, 0+10j, +3+3j]]) # Gx + j*Gy + return scp.signal.convolve2d( + ascent, scharr, boundary='symm', mode='same') + + @testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-5, scipy_name='scp') + def test_convolve2d_2(self, xp, scp): + # see cupy/cupy#6047 + a = xp.array([[257]], dtype="uint64") + b = xp.array([[1]], dtype="uint8") + return scp.signal.convolve2d(a, b, mode="same") + + @testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-5, scipy_name='scp') + def test_convolve2d_3(self, xp, scp): + # see cupy/cupy#6047 + a = xp.array([[257]], dtype="uint64") + b = xp.array([[1]], dtype="uint8") + return scp.signal.convolve2d(b, a, mode="same") + + @testing.gpu @testing.parameterize(*testing.product({ 'mode': ['valid', 'same', 'full']