recent broadcast changes (iterate by default), scalar struct, and `@.`

Because @. is a syntax-level transformation, it doesn’t treat Ref as a special case in any way. So your

@. chi(Ref(m1), energy)

becomes

chi.(Ref.(m1), energy)

which does indeed try to call chi(Ref(m1), e) for each e in energy and thus produces the error you’re seeing.

If you don’t use @., then the Ref works fine:

julia> chi.(Ref(m1), energy)
3-element Array{Float64,1}:
 0.6666666666666666
 0.5               
 0.4 

But I agree that the deprecation warning isn’t very helpful in this case, and you probably won’t be the only person to encounter this issue.

I’m not sure what could be done here. Using a 1-element tuple instead of a Ref also fixes the warning and works fine with @.:

julia> @. chi((m1,), energy)
3-element Array{Float64,1}:
 0.6666666666666666
 0.5               
 0.4 

Perhaps we should be recommending that instead?

6 Likes