You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(I'm not sure what should be done with it but I just thought it's worth recording in the issue. Personally, I think stateful function should be "banned" (i.e., declared to be an undefined behavior) in broadcasting but I've seen, e.g., @mbauman mentioning rand.() is a nice idiom so this is likely not everyone's favorite definition. In general, I think we need to formalize what to be expected from broadcasting. For example, sparse style broadcasting already expects some kind of pureness in the functions.)
The text was updated successfully, but these errors were encountered:
tkf
changed the title
maximum(broadcasted_object) can produce buggy outputs with stateful functions
maximum(::Broadcasted) can produce buggy outputs with stateful functions
May 30, 2020
Combining a stateful function, lazy broadcasted object, and reduction can produce a buggy result.
Here is a demo:
prints
This is because
maximum
go over an array twice:julia/base/reduce.jl
Lines 594 to 609 in acd0e83
This is not new in the sense as it could have happened with something like https://github.com/JuliaArrays/MappedArrays.jl.
(I'm not sure what should be done with it but I just thought it's worth recording in the issue. Personally, I think stateful function should be "banned" (i.e., declared to be an undefined behavior) in broadcasting but I've seen, e.g., @mbauman mentioning
rand.()
is a nice idiom so this is likely not everyone's favorite definition. In general, I think we need to formalize what to be expected from broadcasting. For example, sparse style broadcasting already expects some kind of pureness in the functions.)The text was updated successfully, but these errors were encountered: