Commit 9c5639d
authored
Fix nested broadcasting of BlockedArray (#485)
Fixes #295. That issue seemed to be caused by code in the generic block
broadcasting logic such as
https://github.com/JuliaArrays/BlockArrays.jl/blob/90ddfa96fb0ade3da4f67ac285fcb340350c19c6/src/blockbroadcast.jl#L121-L129
assuming the broadcasting expression is already flat. This PR adds a
call to `Broadcast.flatten` to explicitly flatten the broadcast
expression in the generic block broadcast code.
It appears that at some point `BlockedStyle` broadcasting expressions
were being flattened in this `Broadcast.instantiate` definition:
https://github.com/JuliaArrays/BlockArrays.jl/blob/90ddfa96fb0ade3da4f67ac285fcb340350c19c6/src/blockbroadcast.jl#L199-L202
but that was changed in #193. Reverting that change broke the tests
introduced in #193 so I guess it is not safe to do that.
I have to admit I'm not sure if this is the best place to call
`Broadcast.flatten`, a lot of this broadcasting code is hard to follow.
The place I put it in this PR fixes #295, doesn't break other tests, and
is hopefully least likely to interfere with custom implementations of
block broadcasting in downstream packages.1 parent 3edffcb commit 9c5639d
2 files changed
+23
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
74 | 90 | | |
75 | 91 | | |
76 | 92 | | |
| |||
0 commit comments