Skip to content

Commit

Permalink
Allow CartesianIndices with Bool argument
Browse files Browse the repository at this point in the history
Follow up to the problem discussed in JuliaLang#31829 (comment).

I came to the conclusion that `CartesianIndices((true,))` should be allowed as in this context `true` represents a dimension length not an index.
  • Loading branch information
bkamins authored Mar 9, 2021
1 parent faa3d41 commit fd47846
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ module IteratorsMD

CartesianIndices(A::AbstractArray) = CartesianIndices(axes(A))

_convert2ind(sz::Bool) = Base.OneTo(Int(sz))
_convert2ind(sz::Integer) = Base.OneTo(sz)
_convert2ind(sz::AbstractUnitRange) = first(sz):last(sz)
_convert2ind(sz::OrdinalRange) = first(sz):step(sz):last(sz)
Expand Down

0 comments on commit fd47846

Please sign in to comment.