Skip to content

Commit

Permalink
Add comment in mapslices to explain the wrapping of scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Jul 13, 2018
1 parent 045c19d commit fe68641
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,9 @@ function mapslices(f, A::AbstractArray; dims)
Rsize = copy(dimsA)
# TODO: maybe support removing dimensions
if !isa(r1, AbstractArray) || ndims(r1) == 0
# If the result of f on a single slice is a scalar then we add singleton
# dimensions. When adding adding the dimensions, we have to respect the
# index type of the input array (e.g. in the case of OffsetArrays)
tmp = similar(Aslice, typeof(r1), reduced_indices(Aslice, 1:ndims(Aslice)))
tmp[first(CartesianIndices(tmp))] = r1
r1 = tmp
Expand Down

0 comments on commit fe68641

Please sign in to comment.