[SciPy-user] Unexpected behaviour of convolve2d and correlate2d

Gael Varoquaux gael.varoquaux at normalesup.org
Sun Nov 19 09:38:10 CST 2006


Hi,

I think you have uncovered a bug, this is taken from a ipython session
(I didn't cheat):

In [42]: signal.convolve2d(ones((4,4)), ones((1,15)), 'same', 'wrap')
Out[42]: 
array([[                           nan,                    13.        ,
                           14.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,     15892918649396384.        ,
            15892918649396384.        ,     15892918649396384.        ]])

In [43]: signal.convolve2d(ones((4,4)), ones((1,15)), 'same', 'wrap')
Out[43]: 
array([[                           nan,                    13.        ,
                           14.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    14.        ,
                           13.        ,                    12.        ]])

In [44]: signal.convolve2d(ones((4,4)), ones((1,15)), 'same', 'wrap')
Out[44]: 
array([[                           nan,                    13.        ,
                           14.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    14.        ,
                           13.        ,                    12.        ]])

In [45]: signal.convolve2d(ones((4,4)), ones((1,15)), 'same', 'wrap')
Out[45]: 
array([[                           nan,                    13.        ,
                           14.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    15.        ,
                           15.        ,                    15.        ],
       [                   15.        ,                    14.        ,
                           13.        ,                    12.        ]])

In [46]: signal.convolve2d(ones((4,4)), ones((1,15)), 'same', 'wrap')
Out[46]: 
array([[ 12.,  13.,  14.,  15.],
       [ 15.,  15.,  15.,  15.],
       [ 15.,  15.,  15.,  15.],
       [ 15.,  14.,  13.,  12.]])


Could someone more qualified than me look into this ?

Scipy version is 0.5.1 (ubuntu breezy), and numpy 1.0rc1

 Gaël


More information about the SciPy-user mailing list