-
-
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
Discrepancy b/w map!(f, A)
and broadcast!(f, A)
#12277
Comments
Well, that's a tricky case. I'd argue that the |
I agree that the There are other discrepancies, too, between julia> A = rand(1:2, 10)
10-element Array{Int64,1}:
2
1
1
1
2
2
1
1
2
2
julia> f(x) = x > 1 ? 1.5 : 1
f (generic function with 1 method)
julia> map(f, A)
10-element Array{Real,1}:
1.5
1
1
1
1.5
1.5
1
1
1.5
1.5
julia> broadcast(f, A)
ERROR: InexactError()
in setindex! at array.jl:303
in _F_ at broadcast.jl:98
in broadcast! at broadcast.jl:229
in broadcast at broadcast.jl:236 |
Relevant discussion most recently in #12292. |
But this issue is not about the element type of returned results; it's about whether it's possible to use e.g. |
I was responding to "other discrepancies" part of his post above mine. |
Ah, makes sense.
|
See also #4883. |
Stumbled upon the The behavioral difference between On the one hand, as Similarly, on the one hand Should we call this difference a discrepancy and remedy it, or instead simply call it part of the general behavioral difference between |
I would prefer to have map behave like broadcast here. |
Do you mean have |
(It should not be the same as |
Do we generally guarantee that |
Deprecating (I notice that FunctionalData.jl actually defines |
Would likewise deprecating |
I can't imagine that anyone is using |
@Sacha0, in 0.6 master, I already get: julia> broadcast!(rand, zeros(5))
5-element Array{Float64,1}:
0.103415
0.856194
0.278624
0.714237
0.643863 whereas in Julia 0.5 I get julia> broadcast!(rand, zeros(5))
5-element Array{Float64,1}:
0.969826
0.969826
0.969826
0.969826
0.969826 so it looks like this was already changed? (If you want |
Yes there should (also for the various recent deprecations and feature enhancements) but those can wait until after next week when he gets back from some travel. |
(Breadcrumb to the completed NEWS item for |
After #19721, all that remains here is implementing the behavior change such that |
Since |
None strictly necessary for 1.0 IIRC. Implementing |
Excellent, that's what I thought :) |
Calling
map!
on a singleArray
argument applies the appropriate 1-arg method off
on each element ofA
in-place, whereas callingbroadcast!
on a singleArray
argument replaces each element ofA
with the result of calling the 0-arg method off
:Not sure if this small point bugs anybody, but I thought I'd call it to attention.
The text was updated successfully, but these errors were encountered: