Broadcasting fails to locate namedarray object
Opened this issue · 2 comments
tomhaber commented
The broadcast implementation tries to find the first NamedArray in the expression tree, but fails when a subtree doesn't have a NamedArray. For example:
bc = Base.broadcasted(+, Base.broadcasted(*, [1., 2., 3.], 2.), NamedArray([1,2,3]))
copy(bc) # throws BoundsError: attempt to access () at index [1]
Quick and dirty fix is to add the terminating case
find_namedarray(x::Tuple{}) = ()
I'm not really familiar with broadcasting, but I think the names could be encoded into the broadcast-style as well.
davidavdav commented
I've just been dealing with this broadcasting code... I didn't write it so I had to study it a little. What is the actual use case for this error? I assume you don't work with raw Base.broadcasted
?
tomhaber commented
Oh no, definitely not. The actual use case is
[1., 2., 3.] .* 2 .+ NamedArray([1,2,3])
If I remember correctly, the problem occurs when the NamedArray is on the right side of the expression tree