Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcasting fails to locate namedarray object #103

Open
tomhaber opened this issue Nov 21, 2020 · 2 comments
Open

Broadcasting fails to locate namedarray object #103

tomhaber opened this issue Nov 21, 2020 · 2 comments

Comments

@tomhaber
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

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

tomhaber added a commit to tomhaber/NamedArrays.jl that referenced this issue Oct 2, 2021
the broadcast-style way might be a better way to deal with broadcasting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants