Allow DefaultArrayStyle to be broadcast according to normal rules - #138
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hot fix to #137
The original issue lies in the way broadcasting works for
zeros(), sincezeros().+2.0gets turned fromArray{Float64, 0}intoFloat64, because apparently that is how broadcasting is set up forDefaultArrayStyle{0}(This seems like a bug in Julia.) Before #136, this wasn't a problem for broadcasting ofArrayPartitionas long as anArray{Float64, 0}was paired with another component of higherArrayrank, e.g.,ap = ArrayPartition(zeros(),[1.0]), since they would all be broadcast viaDefaultArrayStyle{1}rules. Soap+1.0would be of the same type asap. But on its own, e.g.,ap = ArrayPartition(zeros()), thenap + 1.0would not be the same type asap, since it gets broadcast as aDefaultArrayStyle{0}. Unfortunately, #136 exposed this issue.This PR provides a more narrowly defined scope for when components of ArrayPartition will change their style in
unpackfrom that of the promoted style of the overall Broadcasted wrapper of the ArrayPartition. If it is ofDefaultArrayStyle, then it keeps the overall wrapper's style, thereby preserving the behavior before #136. But if the ArrayPartition contains a custom type with its own BroadcastStyle, then it parses the components' styles and therefore still allows specialized dispatch oncopy.