-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Specialize promotion for concatenations #19523
Conversation
I don't think |
@nalimilan You're right. For now I guess I could go with the second approach for the sake of having concatenations working properly and leave the discussion of a general interface for later. |
6a0e0ad
to
cb060d8
Compare
I think we should avoid adding another ad hoc julia> filter(t -> ismatch(r"promote", string(t)) && ismatch(r"^((?!\#).)*$", string(t)), names(Base, true))
15-element Array{Symbol,1}:
:promote
:promote_array_type
:promote_eltype
:promote_eltype_op
:promote_op
:promote_result
:promote_rule
:promote_shape
:promote_to_supertype
:promote_type
:promote_typeof
:promote_union
:r_promote
:r_promote_type
:rcum_promote_type If this only fixes |
@andreasnoack I was hesitant about this given all the This should help with part of #19387 (comment). |
I'd like to unify some of the |
That would be great and I agree that it belongs in another PR. |
Even if the breakage is in my package, I'm not sure we need to restore the previous behavior for But the new/current behavior does not sound correct either, since Anyway I now see that there already are special cases for |
@nalimilan My perception is that the Additionally, here is an example that fails with the new behavior, that should work, and that this PR fixes vcat((1,), (2.0,))
# currently fails trying to construct a Vector{Float64}
# but after this PR returns
Tuple{Real}[(1,), (2.0,)] |
48d2af0
to
8827670
Compare
8827670
to
e72518e
Compare
That's fine with me, I'm not familiar enough with that code to say what's the best solution. |
Shouldn't the decision about whether an object has a shape be the same as for |
If that were there consensus we would have 4×2 Array{Int64,2}:
1 1
1 2
2 2
1 2 though, I wouldn't have a problem with this. I was just trying to get back the original behavior for now (as there are some packages relying on it that are broken right now). If people feel that we should change the behavior here, I can accommodate whatever is decided. Alternatively, we could open an issue to discuss this and make the appropriate changes in another PR. |
Indeed that doesn't sound like the most common need. I'd say let's restore the previous behavior, and discuss this more thoroughly in another issue. |
Is it critical? I don't know how closely we tracked whether this fixed every single one of the package issues from #19387, and I'm trying to get the backports wrapped up. |
I'm pretty confident that this fixed the issue from #19387. But it's certainly not critical, so it wouldn't be too bad if this doesn't make it into 0.5. |
Currently for concatenation purposes, we need promotion mechanism that takes
eltype
s ofAbstractArray
s andtypeof
of anything else and promotes these (see #19387 (comment)).There are two proposals that occur to me to handle this:
eltypeof
(oreltype_or_typeof
) method that gives the appropriate type depending on the argument and pass that topromote_eltype
(this PR)promote_eltypeof
that handles properly mixtures ofAbstractArray
s and scalars leavingpromote_eltype
alone (this PR).The first approach shouldn't change the behavior of
promote_eltype
when called overAbstractArray
s only,that's why I'm inclined to go that routebut a proper interface would have to be decided given how things like strings are both scalar and collection under different circumstances. Anyway, it'd be useful to see what other people think.