Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Minor cleanup of BitArray constructors to fully allow Integer types (J…
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed May 31, 2016
1 parent 1dd6fe2 commit 301156b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type BitArray{N} <: DenseArray{Bool, N}
end

BitArray{N}(dims::NTuple{N,Int}) = BitArray{N}(dims...)
BitArray(dims::Int...) = BitArray(dims)
BitArray(dims::Integer...) = BitArray(map(Int,dims))

typealias BitVector BitArray{1}
typealias BitMatrix BitArray{2}
Expand Down Expand Up @@ -386,7 +386,7 @@ end
Create a `BitArray` with all values set to `false`.
"""
falses(dims::Dims) = fill!(BitArray(dims), false)
falses(dims::Integer...) = falses(dims)
falses(dims::Integer...) = falses(map(Int,dims))
"""
falses(A)
Expand All @@ -400,7 +400,7 @@ falses(A::AbstractArray) = falses(size(A))
Create a `BitArray` with all values set to `true`.
"""
trues(dims::Dims) = fill!(BitArray(dims), true)
trues(dims::Integer...) = trues(dims)
trues(dims::Integer...) = trues(map(Int,dims))
"""
trues(A)
Expand Down
13 changes: 13 additions & 0 deletions test/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1341,3 +1341,16 @@ uv = Array(v)
B = bitrand(10,10)
uB = Array(B)
@test diag(uB) == Array(diag(B))

# test non-Int dims constructor
A = BitArray(Int32(10))
B = BitArray(Int64(10))
@test A == B

A = trues(Int32(10))
B = trues(Int64(10))
@test A == B

A = falses(Int32(10))
B = falses(Int64(10))
@test A == B

0 comments on commit 301156b

Please sign in to comment.