Skip to content

Commit

Permalink
fix A[]=x for Array and BitArray
Browse files Browse the repository at this point in the history
fix gen_cartesian_map in the case of ranges===()
  • Loading branch information
JeffBezanson committed Jun 1, 2013
1 parent 8e74531 commit 5af0445
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ end
## specifies what it wants to do before and after each loop.
## If genbodies creates an array it must of length N.
function gen_cartesian_map(cache, genbodies, ranges, exargnames, exargs...)
if ranges === ()
ranges = (1,)
end
N = length(ranges)
if !haskey(cache,N)
if isdefined(genbodies,:code)
Expand Down
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ getindex{T<:Real}(A::Matrix, I::AbstractVector{T}, J::AbstractVector{Bool}) = A[
getindex{T<:Real}(A::Matrix, I::AbstractVector{Bool}, J::AbstractVector{T}) = A[find(I),J]

## Indexing: setindex! ##
setindex!{T}(A::Array{T,0}, x) = arrayset(A, convert(T,x), 1)
setindex!{T}(A::Array{T}, x) = arrayset(A, convert(T,x), 1)

setindex!(A::Array{Any}, x::ANY, i::Real) = arrayset(A, x, to_index(i))

Expand Down
4 changes: 4 additions & 0 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ end

getindex(B::BitArray, i::Real) = getindex(B, to_index(i))

getindex(B::BitArray) = getindex(B, 1)

# 0d bitarray
getindex(B::BitArray{0}) = getindex_unchecked(B.chunks, 1)

Expand Down Expand Up @@ -476,6 +478,8 @@ function setindex!(B::BitArray, x::Bool, i::Int)
return B
end

setindex!(B::BitArray, x) = setindex!(B, x, 1)

setindex!(B::BitArray, x, i::Real) = setindex!(B, convert(Bool,x), to_index(i))

setindex!(B::BitArray, x, i0::Real, i1::Real) =
Expand Down

0 comments on commit 5af0445

Please sign in to comment.