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

Behavior of Ref in broadcast #24880

Closed
goretkin opened this issue Dec 1, 2017 · 4 comments
Closed

Behavior of Ref in broadcast #24880

goretkin opened this issue Dec 1, 2017 · 4 comments
Labels
broadcast Applying a function over a collection

Comments

@goretkin
Copy link
Contributor

goretkin commented Dec 1, 2017

I understand Ref as a length-1 array (tell me how flawed this is), but that's not how it behaves in a broadcast. From the discussion at https://discourse.julialang.org/t/broadcasting-and-arrays-of-arrays/7444/5 :

julia> [1, 2] .- Ref([1, 2])  # behaves like [1, 2] .- [1]
2-element Array{Int64,1}:
 0
 1

julia> [1, 2] .- [[1, 2]]
2-element Array{Array{Int64,1},1}:
 [0, -1]
 [1, 0] 

(thanks @rdeits )

@timholy
Copy link
Sponsor Member

timholy commented Dec 2, 2017

One part of the problem is

julia> eltype(Ref([1,2]))
Int64

julia> eltype(Ref(3))
Int64

That seems broken.

@KristofferC
Copy link
Sponsor Member

Ah, the classical #15303 mixup.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 2, 2017

I think that’s actually #21527

@mbauman mbauman added the broadcast Applying a function over a collection label Apr 24, 2018
@vtjnash
Copy link
Sponsor Member

vtjnash commented May 5, 2018

will be fixed when deprecations get deleted

julia> eltype(Ref{Vector{Int}}([1,2]))
Array{Int64,1}

@vtjnash vtjnash closed this as completed May 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broadcast Applying a function over a collection
Projects
None yet
Development

No branches or pull requests

5 participants