@@ -152,6 +152,9 @@ const NamedDimsAxis = AbstractNamedUnitRange{
152152
153153# Generic constructor.
154154function nameddims (a:: AbstractArray , nameddimsindices)
155+ if iszero (ndims (a))
156+ return constructorof_nameddims (typeof (a))(a, nameddimsindices)
157+ end
155158 # TODO : Check the shape of `nameddimsindices` matches the shape of `a`.
156159 arrtype = mapreduce (nameddimsarraytype, combine_nameddimsarraytype, nameddimsindices)
157160 return arrtype (a, to_nameddimsindices (a, nameddimsindices))
@@ -781,7 +784,7 @@ function set_promote_shape(
781784 ax1:: Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}} ,
782785 ax2:: Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}} ,
783786) where {N}
784- perm = getperm (ax1, ax2 )
787+ perm = getperm (ax2, ax1 )
785788 ax2_aligned = map (i -> ax2[i], perm)
786789 ax_promoted = promote_shape (dename .(ax1), dename .(ax2_aligned))
787790 return named .(ax_promoted, name .(ax1))
@@ -813,7 +816,7 @@ function set_check_broadcast_shape(
813816 ax1:: Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}} ,
814817 ax2:: Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}} ,
815818) where {N}
816- perm = getperm (ax1, ax2 )
819+ perm = getperm (ax2, ax1 )
817820 ax2_aligned = map (i -> ax2[i], perm)
818821 check_broadcast_shape (dename .(ax1), dename .(ax2_aligned))
819822 return nothing
0 commit comments