@@ -21,17 +21,28 @@ Base.BroadcastStyle(::Type{<:KeyedArray{T,N,AT}}) where {T,N,AT} =
2121Base. BroadcastStyle (:: KeyedStyle{A} , :: KeyedStyle{B} ) where {A, B} = KeyedStyle (A (), B ())
2222Base. BroadcastStyle (:: KeyedStyle{A} , b:: B ) where {A, B} = KeyedStyle (A (), b)
2323Base. BroadcastStyle (a:: A , :: KeyedStyle{B} ) where {A, B} = KeyedStyle (a, B ())
24- Base. BroadcastStyle (:: KeyedStyle{A} , b:: DefaultArrayStyle ) where {A} = KeyedStyle (A (), b)
25- Base. BroadcastStyle (a:: AbstractArrayStyle{M} , :: KeyedStyle{B} ) where {B,M} = KeyedStyle (a, B ())
2624
2725using NamedDims: NamedDimsStyle
2826# this resolves in favour of KeyedArray(NamedDimsArray())
2927Base. BroadcastStyle (a:: NamedDimsStyle , :: KeyedStyle{B} ) where {B} = KeyedStyle (a, B ())
3028Base. BroadcastStyle (:: KeyedStyle{A} , b:: NamedDimsStyle ) where {A} = KeyedStyle (A (), b)
3129
30+ # Resolve ambiguities
31+ # for all these cases, we define that we win to be the outer style regardless of order
32+ for B in (
33+ :BroadcastStyle , :DefaultArrayStyle , :AbstractArrayStyle , :(Broadcast. Style{Tuple}),
34+ )
35+ @eval function Base. BroadcastStyle (:: KeyedStyle{A} , b:: $B ) where A
36+ return KeyedStyle (A (), b)
37+ end
38+ @eval function Base. BroadcastStyle (b:: $B , :: KeyedStyle{A} ) where A
39+ return KeyedStyle (b, A ())
40+ end
41+ end
42+
3243function unwrap_broadcasted (bc:: Broadcasted{KeyedStyle{S}} ) where {S}
3344 inner_args = map (unwrap_broadcasted, bc. args)
34- Broadcasted {S} (bc. f, inner_args)
45+ Broadcasted {S} (bc. f, inner_args, axes (bc) )
3546end
3647unwrap_broadcasted (x) = x
3748unwrap_broadcasted (x:: KeyedArray ) = parent (x)
0 commit comments