How do you access the conv function in Julia 1.0.0

Viewed 4229

This question on stackoverflow uses Julia 0.6.1, as shown here:

The convolution function in Julia has the following behaviour:

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.1 (2017-10-24 22:15 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> conv([1,2,NaN],[1])

3-element Array{Float64,1}:
 NaN
 NaN
 NaN

The same thing in Julia 1.0.0 produces the following Error output:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.0 (2018-08-08)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> conv([1,2,NaN],[1])
ERROR: UndefVarError: conv not defined
Stacktrace:
 [1] top-level scope at none:0

How does one access the conv function in Julia 1.0.0?

1 Answers

The convolution function has been moved to the package DSP.jl which stands for Digital Signal Processing.

It is generally recommended to use Julia v0.7 when trying to port pre v0.7 code to Julia v1.0. In fact, this is the only reason v0.7 exists.

When calling conv in v0.7 you get all the information you need:

julia> conv(rand(10))
ERROR: conv has been moved to the package DSP.jl.
Run `Pkg.add("DSP")` to install it, restart Julia,
and then run `using DSP` to load it.

In case you'd want to avoid running v0.7 on you machine just to find out where something has been moved to, you can also search for the old function's name in deprecated.jl. Searching for conv we find:

for f in [:conv, :conv2, :deconv, :filt, :filt!, :xcorr]
    @eval Base.@deprecate_moved $f "DSP"
end

Although source code, I believe @deprecate_moved "DSP" is understandable.

Related