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

array of array promotion #24988

Closed
StefanKarpinski opened this issue Dec 8, 2017 · 4 comments
Closed

array of array promotion #24988

StefanKarpinski opened this issue Dec 8, 2017 · 4 comments
Assignees
Labels
domain:arrays [a, r, r, a, y, s]
Milestone

Comments

@StefanKarpinski
Copy link
Sponsor Member

Intersting promotion example here: https://discourse.julialang.org/t/what-on-earth-does-any-do/7625/5. In short, this is good:

julia> [ [1, 2, 3], [1, 0.5, 0.25, 0.125], [-1, -2] ]
3-element Array{Array{Float64,1},1}:
 [1.0, 2.0, 3.0]
 [1.0, 0.5, 0.25, 0.125]
 [-1.0, -2.0]

But this is less good:

julia> [ [1, 2, 3], ["1", "2", "3"], [1.0, 2.0, 3.0] ]
3-element Array{Array{Any,1},1}:
 Any[1, 2, 3]
 Any["1", "2", "3"]
 Any[1.0, 2.0, 3.0]

Perhaps array promotion should not try to convert all arrays to the same element type unless that element type is concrete.

@StefanKarpinski StefanKarpinski added the status:triage This should be discussed on a triage call label Dec 8, 2017
@Liso77
Copy link

Liso77 commented Dec 8, 2017

IMHO explicit is better than implicit also in this case.
So rather than:

julia> repr(Any[ [1, 2, 3], [1, 0.5, 0.25, 0.125], [-1, -2] ])
"Any[[1, 2, 3], [1.0, 0.5, 0.25, 0.125], [-1, -2]]"

julia> repr([ [1, 2, 3], [1, 0.5, 0.25, 0.125], [-1, -2] ])
"Array{Float64,1}[[1.0, 2.0, 3.0], [1.0, 0.5, 0.25, 0.125], [-1.0, -2.0]]"

I like to see:

julia> repr([ [1, 2, 3], [1, 0.5, 0.25, 0.125], [-1, -2] ])
"[[1, 2, 3], [1.0, 0.5, 0.25, 0.125], [-1, -2]]"

julia> repr(Array{Float64,1}[ [1, 2, 3], [1, 0.5, 0.25, 0.125], [-1, -2] ])
"Array{Float64,1}[[1.0, 2.0, 3.0], [1.0, 0.5, 0.25, 0.125], [-1.0, -2.0]]"

@StefanKarpinski StefanKarpinski added this to the 1.0 milestone Dec 14, 2017
@StefanKarpinski StefanKarpinski added domain:arrays [a, r, r, a, y, s] and removed status:triage This should be discussed on a triage call labels Dec 14, 2017
@JeffBezanson
Copy link
Sponsor Member

Wasn't this already changed by #22757?

julia> [ [1, 2, 3], ["1", "2", "3"], [1.0, 2.0, 3.0] ]
3-element Array{Array{T,1} where T,1}:
 [1, 2, 3]      
 ["1", "2", "3"]
 [1.0, 2.0, 3.0]

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 15, 2017

Looms like it. That’s what I was expecting to need to implement. @StefanKarpinski what’s up with you example not matching Jeff’s result?

@StefanKarpinski
Copy link
Sponsor Member Author

My mistake! I must have run the example in a 0.6 session – I've been running 0.6 for Pkg3 for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays [a, r, r, a, y, s]
Projects
None yet
Development

No branches or pull requests

4 participants