-
-
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
Use only safe axis types for Broadcast.combine_axes #30164
Conversation
#30074 used the wrong notion of consistency since `OneTo(1)` is consistent (wrt broadcasting) with any range, but `OneTo` cannot handle `Slice(-1:1)`.
Is this really just |
It's effectively promote_rule(::Type{T1}, ::Type{T2}) where {T1<:AbstractUnitRange,T2<:AbstractUnitRange} = UnitRange{Int} but limited to broadcasting (without the consequent fallout elsewhere). Since Of course one might wonder whether we want that rule anyway. This is being conservative and limiting the domain of applicability. |
To explain the complexities a bit more, consider the following:
The These objects raise interesting questions with regards to how construction and Bugs noticed while writing this postCurrent behavior: julia> -1:1 == Base.Slice(-1:1)
true but julia> using OffsetArrays
julia> collect(-1:1) == OffsetArray(collect(-1:1), (-2,))
false This, I think, has to be fixed. More questionable is whether |
cc @mbauman |
Breaks a package on 1.0 so removing from backport. |
#30074 used the wrong notion of consistency since
OneTo(1)
is consistent (wrt broadcasting) with any range, butOneTo
cannot handleSlice(-1:1)
.I also changed the name to something a bit more "override-worthy." I don't think anyone should ever need to do so (the BroadcastStyle is in charge of output container type), but given that we allow axes to determine output from
similar
it seemed safer to set this up in a way that isn't inconsistent with potential extensions.