Potential error in the performance tips page

Hello, I am new to Julia. I was working through the examples on the performance tips page when I ran into this code in the types with values-as-parameters section. The example code is included below as well.

function array3(fillval, ::Val{N}) where N
    fill(fillval, ntuple(d->3, Val(N)))
end

function filter3(A::AbstractArray{T,N}) where {T,N}
    kernel = array3(1, Val(N))
    filter(A, kernel)
end

There seems to be an error when the example calls filter() with an AbstractArray as an argument where a function is expected.

1 Like

As you say, the example code would throw an error. Good catch!

The filter is probably a placeholder name (like foo) that is assumed to be a convolution filter, not Base.filter.

That can be assumed from the context and the term kernel, but without such prior knowledge, it is certainly unkind.
Also, it is not recommended to define a function named filter, as DSP.jl uses the function name filt instead of filter.

So I think this is worth being filed as an issue.

2 Likes

xref: Confusing error in the performance tips page · Issue #54170 · JuliaLang/julia · GitHub

2 Likes