[SciPy-dev] Note on changeset 5878: Add old_behavior arg for convolve2d and correlate2d

David Cournapeau david at ar.media.kyoto-u.ac.jp
Wed Oct 7 23:11:42 EDT 2009


Pearu Peterson wrote:
> Hi,
>
> Currently scipy.signal.convolve gives the following warning by default:
>
> """
> Current default behavior of convolve and correlate functions is deprecated.
>
> Convolve and corelate currently swap their arguments if the second argument
> has dimensions larger than the first one, and the mode is relative to
> the input
> with the largest dimension. The new behavior is to never swap the
> inputs, which
> is what most people expects, and is how correlation is usually defined.
>
> You can control the behavior with the old_behavior flag - the flag will
> disappear in scipy 0.9.0, and the functions will then implement the new
> behavior only.
> """
>
> The problem right now is that it is difficult to write a stable
> application that would not give this warning.
> Using old_behavior=False argument means that when upgrading to scipy
> 0.9.0, the application will become broken because the kw argument will
> be removed. In my application the old and new behaviors are identical.
>
> My suggestion is to raise the deprecation warning only when the old
> and the new behavior are in conflict.

Yes, that's a good idea. I will try to fix this today, ping me if I forgot

>  For example, consider the diff below.
>
> What do you think?
>
> Pearu
>
> $ svn diff signaltools.py
> Index: signaltools.py
> ===================================================================
> --- signaltools.py	(revision 5953)
> +++ signaltools.py	(working copy)
> @@ -100,10 +100,11 @@
>      val = _valfrommode(mode)
>
>      if old_behavior:
> -        warnings.warn(DeprecationWarning(_SWAP_INPUTS_DEPRECATION_MSG))
>          if np.iscomplexobj(in2):
> +            # hmm, how is this related to deprecation warning?
>              in2 = in2.conjugate()

There is a doc problem here: the new behavior is not only to never swap
inputs, but also to take the conjugate of the second argument (that is
the usual definition of convolution).

cheers,

David



More information about the SciPy-Dev mailing list