-
-
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
Support broadcasting for Set
#23746
Comments
More confusingly, two argument julia> map(+, Set([1,2,3]), Set([4,5,6]))
3-element Array{Int64,1}:
6
8
7 |
The order of iteration over a Since we define |
Sorry, that was the point I was trying to make: |
In an ideal world, the following would also work: Set([1,2,3]) .+ 2 |
My intuitive expectation for broadcasting over sets is to operate on the cartesian product, since the math notation |
That might be a reasonable definition for |
Note that currently a
Would we want to keep that behavior for mixing arrays and sets? That could get confusing, if a My inclination is to just say that you need to use |
The issue with only allowing function foo(s::Set,k::Number)
map(x->x+k, s)
end If broadcasting is supported, then this can be done via function foo(s::Set,k::Number)
broadcast(+, s, k)
end For the issue of precedence: I also came across this in ApproxFun, where both array's and I think this solution would be reasonable for promote_containertype(::Type{Set}, ::Type{Set}) = Set
promote_containertype(::Type{Array}, ::Type{Set}) = Array
promote_containertype(::Type{Set}, ::Type{Array}) = Array
promote_containertype(::Type{Set}, ct) = Set
promote_containertype(ct, ::Type{Set}) = Set |
Considering that sets don't have a natural order, I'm not sure what this behavior (for cases with >1 argument) even means. Is |
We decided to stick with the enumerated plan in #26980 that I had initially implemented. |
* Remove scalar .= deprecation * Remove to_index(::Bool) deprecation * broadcasting now falls back to iteration (fixes #23197, fixes JuliaLang#23746)
* Remove scalar .= deprecation * Remove to_index(::Bool) deprecation * broadcasting now falls back to iteration (fixes #23197, fixes #23746)
I'm surprised this doesn't work:
The text was updated successfully, but these errors were encountered: