-
-
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: Drop BroadcastStyle back down to the value domain #26941
Conversation
Maybe provide a |
That gives me pause since we support types themselves in broadcast, leading to a potential ambiguity in meaning when doing, e.g., |
That fallback would presumably be in a |
It should be fine as a deprecated method, but otherwise I agree the ambiguity would be annoying. However this raises a broader issue regarding other traits. For example, |
This is complicated to deprecate because we already have an julia> using StaticArrays
julia> v = @SArray [1,2,3]
3-element SArray{Tuple{3},Int64,1,3}:
1
2
3
julia> v .* 3
┌ Warning: the BroadcastStyle API is changing. The implementation of StaticArrays.StaticArrayStyle{1}() should work on values, not types.
│ caller = Type at broadcast.jl:100 [inlined]
└ @ Core broadcast.jl:100
3-element Array{Int64,1}:
3
6
9 The broadcast API changed, so while we got the I don't think a fragile deprecation mechanism here is worth the trouble. |
1a9d9f6
to
7fd3a9d
Compare
I'm trying to figure out just how important this is. I do agree that, in general, we want to do these sorts of computations in the type domain. In this case, though, I'm having a hard time imagining what sort of situation you'd want to pre-compute a You may want to explicitly call a given I suppose one might want to "swap out" a given argument and do the computation as though it were a different type. That'd be a situation where you'd want a type-based mechanism. I'm still in favor of this PR. |
7fd3a9d
to
567b27c
Compare
This is a subtle change for broadcast implementors -- instead of defining `BroadcastStyle(::Type{<:MyType})`, they now need to define `BroadcastStyle(::MyType)` directly. This is a breaking change to a new API in 0.7; so it's not technically breaking over 0.6, but any libraries that have adapted to the new API will need to shift their definitions. The primary purpose of this change is becasue the `BroadcastStyle` needs to know about the `ndims` of its passed argument, but some arguments (like PyArrays) don't encode ndims in the type domain. Asking the value directly allows them to participate more fully in the broadcast interface.
567b27c
to
7b5d9b4
Compare
Linux failures were "Process timed out possibly waiting for a response. Process output found:\n"""\nPrivate key location for 'git@github.com':..." 32 bit appveyor timed out. |
I generally favor using the value domain instead of types, but our other traits operate on types, so I hesitate to do this. Instead, for example, PyArray could have a wrapper type that moves the number of dimensions to a type parameter. It seems like that would be needed anyway e.g. for all the dispatch we do on matrix vs. vector. |
Triage concludes that any array type that doesn't have the dimensionality in the type is going to be pretty broken in Julia lang; other languages may change dimensionality at runtime but Julia doesn't and is at some fairly deep level against doing so. So the solution here seems to be always capturing the number of dimensions in the type. |
This is a subtle change for broadcast implementors -- instead of defining
BroadcastStyle(::Type{<:MyType})
, they now need to defineBroadcastStyle(::MyType)
directly. This is a breaking change to a new API in 0.7; so it's not technically breaking over 0.6, but any libraries that have adapted to the new API will need to shift their definitions. The primary purpose of this change is becasue theBroadcastStyle
needs to know about thendims
of its passed argument, but some arguments (like PyArrays) don't encode ndims in the type domain. Asking the value directly allows them to participate more fully in the broadcast interface.Ref #26601 (comment).