[Scipy-tickets] [SciPy] #1411: scipy.signal.correlate gives different results than numpy.correlate

SciPy Trac scipy-tickets@scipy....
Fri Mar 18 07:38:40 CDT 2011


#1411: scipy.signal.correlate gives different results than numpy.correlate
--------------------------+-------------------------------------------------
 Reporter:  jpaalasm      |       Owner:  somebody
     Type:  defect        |      Status:  new     
 Priority:  normal        |   Milestone:  0.10.0  
Component:  scipy.signal  |     Version:  0.9.0   
 Keywords:                |  
--------------------------+-------------------------------------------------
 The correlation functions from scipy.signal and numpy work differently. Is
 there a reason for this?

 Moreover, the error message raised by scipy.signal.correlate is not very
 informative.

 {{{
 In [28]: scipy.__version__, numpy.__version__
 Out[28]: ('0.9.0', '1.5.1')
 In [29]: scipy.signal.correlate(scipy.arange(2), scipy.arange(4), 'valid')
 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call
 last)

 /home/ubuntu/<ipython console> in <module>()

 /usr/local/lib/python2.6/dist-
 packages/scipy.egg/scipy/signal/signaltools.pyc in correlate(in1, in2,
 mode)
      84     if mode == 'valid':
      85         ps = [i - j + 1 for i, j in zip(in1.shape, in2.shape)]
 ---> 86         out = np.empty(ps, in1.dtype)
      87         for i in range(len(ps)):
      88             if ps[i] <= 0:

 ValueError: negative dimensions are not allowed

 In [30]: numpy.correlate(scipy.arange(2), scipy.arange(4), 'valid')
 Out[30]: array([3, 2, 1])

 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1411>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list