From 48cdc2fce9b0433b1c9ea4dbd9a4852080a7f1ed Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Fri, 22 Apr 2016 17:09:58 -0400 Subject: [PATCH] deprecate bitpack/unpack in favor of BitArray/Array constructors --- base/bitarray.jl | 38 ++++----- base/broadcast.jl | 6 +- base/deprecated.jl | 2 + base/docs/helpdb/Base.jl | 14 ---- base/exports.jl | 2 - base/linalg/bitarray.jl | 10 +-- base/linalg/uniformscaling.jl | 12 +-- test/arrayops.jl | 16 ++-- test/bitarray.jl | 142 +++++++++++++++++----------------- test/broadcast.jl | 8 +- test/hashing.jl | 2 +- test/reduce.jl | 2 +- 12 files changed, 118 insertions(+), 136 deletions(-) diff --git a/base/bitarray.jl b/base/bitarray.jl index 25775041244b95..70cb4891fc3d70 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -532,10 +532,6 @@ convert{T,N}(::Type{AbstractArray{T,N}}, B::BitArray{N}) = convert(Array{T,N}, B reinterpret{N}(::Type{Bool}, B::BitArray, dims::NTuple{N,Int}) = reinterpret(B, dims) reinterpret{N}(B::BitArray, dims::NTuple{N,Int}) = reshape(B, dims) -# shorthand forms BitArray <-> Array -bitunpack{N}(B::BitArray{N}) = convert(Array{Bool,N}, B) -bitpack{T,N}(A::AbstractArray{T,N}) = convert(BitArray{N}, A) - ## Indexing: getindex ## @inline function unsafe_bitgetindex(Bc::Vector{UInt64}, i::Int) @@ -665,8 +661,8 @@ function append!(B::BitVector, items::BitVector) return B end -append!(B::BitVector, items::AbstractVector{Bool}) = append!(B, bitpack(items)) -append!(A::Vector{Bool}, items::BitVector) = append!(A, bitunpack(items)) +append!(B::BitVector, items::AbstractVector{Bool}) = append!(B, BitArray(items)) +append!(A::Vector{Bool}, items::BitVector) = append!(A, Array(items)) function prepend!(B::BitVector, items::BitVector) n0 = length(B) @@ -687,8 +683,8 @@ function prepend!(B::BitVector, items::BitVector) return B end -prepend!(B::BitVector, items::AbstractVector{Bool}) = prepend!(B, bitpack(items)) -prepend!(A::Vector{Bool}, items::BitVector) = prepend!(A, bitunpack(items)) +prepend!(B::BitVector, items::AbstractVector{Bool}) = prepend!(B, BitArray(items)) +prepend!(A::Vector{Bool}, items::BitVector) = prepend!(A, Array(items)) function sizehint!(B::BitVector, sz::Integer) ccall(:jl_array_sizehint, Void, (Any, UInt), B.chunks, num_bit_chunks(sz)) @@ -1068,19 +1064,19 @@ end for f in (:/, :\) @eval begin - ($f)(A::BitArray, B::BitArray) = ($f)(bitunpack(A), bitunpack(B)) + ($f)(A::BitArray, B::BitArray) = ($f)(Array(A), Array(B)) end end -(/)(B::BitArray, x::Number) = (/)(bitunpack(B), x) -(/)(x::Number, B::BitArray) = (/)(x, bitunpack(B)) +(/)(B::BitArray, x::Number) = (/)(Array(B), x) +(/)(x::Number, B::BitArray) = (/)(x, Array(B)) function div(A::BitArray, B::BitArray) shp = promote_shape(size(A), size(B)) all(B) || throw(DivideError()) return reshape(copy(A), shp) end -div(A::BitArray, B::Array{Bool}) = div(A, bitpack(B)) -div(A::Array{Bool}, B::BitArray) = div(bitpack(A), B) +div(A::BitArray, B::Array{Bool}) = div(A, BitArray(B)) +div(A::Array{Bool}, B::BitArray) = div(BitArray(A), B) function div(B::BitArray, x::Bool) return x ? copy(B) : throw(DivideError()) end @@ -1100,8 +1096,8 @@ function mod(A::BitArray, B::BitArray) all(B) || throw(DivideError()) return falses(shp) end -mod(A::BitArray, B::Array{Bool}) = mod(A, bitpack(B)) -mod(A::Array{Bool}, B::BitArray) = mod(bitpack(A), B) +mod(A::BitArray, B::Array{Bool}) = mod(A, BitArray(B)) +mod(A::Array{Bool}, B::BitArray) = mod(BitArray(A), B) function mod(B::BitArray, x::Bool) return x ? falses(size(B)) : throw(DivideError()) end @@ -1157,10 +1153,10 @@ for f in (:&, :|, :$) Fc[end] &= _msk_end(F) return F end - ($f)(A::DenseArray{Bool}, B::BitArray) = ($f)(bitpack(A), B) - ($f)(B::BitArray, A::DenseArray{Bool}) = ($f)(B, bitpack(A)) - ($f)(x::Number, B::BitArray) = ($f)(x, bitunpack(B)) - ($f)(B::BitArray, x::Number) = ($f)(bitunpack(B), x) + ($f)(A::DenseArray{Bool}, B::BitArray) = ($f)(BitArray(A), B) + ($f)(B::BitArray, A::DenseArray{Bool}) = ($f)(B, BitArray(A)) + ($f)(x::Number, B::BitArray) = ($f)(x, Array(B)) + ($f)(B::BitArray, x::Number) = ($f)(Array(B), x) end end @@ -1233,8 +1229,8 @@ end (.*)(x::Bool, B::BitArray) = x & B (.*)(B::BitArray, x::Bool) = B & x -(.*)(x::Number, B::BitArray) = x .* bitunpack(B) -(.*)(B::BitArray, x::Number) = bitunpack(B) .* x +(.*)(x::Number, B::BitArray) = x .* Array(B) +(.*)(B::BitArray, x::Number) = Array(B) .* x ## promotion to complex ## diff --git a/base/broadcast.jl b/base/broadcast.jl index 0c1a4c4fc20256..d68323a3024979 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -328,8 +328,8 @@ for (f, scalarf, bitf, bitfbody) in ((:.==, :(==), :biteq , :(~a $ b)), end F = BitArray(shape) Fc = F.chunks - Ac = bitpack(A).chunks - Bc = bitpack(B).chunks + Ac = BitArray(A).chunks + Bc = BitArray(B).chunks if !isempty(Ac) && !isempty(Bc) for i = 1:length(Fc) - 1 Fc[i] = ($bitf)(Ac[i], Bc[i]) @@ -430,7 +430,7 @@ for (sigA, sigB) in ((BitArray, BitArray), (BitArray, AbstractArray{Bool})) @eval function (.*)(A::$sigA, B::$sigB) try - return bitpack(A) & bitpack(B) + return BitArray(A) & BitArray(B) catch return bitbroadcast(&, A, B) end diff --git a/base/deprecated.jl b/base/deprecated.jl index 5b4c4b1ec691c6..1bee11aa391af6 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1070,6 +1070,8 @@ end @deprecate specialized_bitwise_unary(f::Function) f @deprecate specialized_bitwise_binary(f::Function) f +@deprecate bitunpack(B::BitArray) Array(B) +@deprecate bitpack(A::AbstractArray) BitArray(A) # During the 0.5 development cycle, do not add any deprecations below this line # To be deprecated in 0.6 diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index a1edb8279b6bae..b941f5969884c9 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -4374,13 +4374,6 @@ Pick a random element or array of random elements from the set of values specifi """ rand -""" - bitpack(A::AbstractArray{T,N}) -> BitArray - -Converts a numeric array to a packed boolean array. -""" -bitpack - """ base(base, n, [pad]) @@ -8184,13 +8177,6 @@ all elements of the string. """ ispunct -""" - bitunpack(B::BitArray{N}) -> Array{Bool,N} - -Converts a packed boolean array to an array of booleans. -""" -bitunpack - """ size(A, [dim...]) diff --git a/base/exports.jl b/base/exports.jl index 704e4ff233e88c..70d3cac5f8083a 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -723,8 +723,6 @@ export full, # bitarrays - bitpack, - bitunpack, falses, flipbits!, rol, diff --git a/base/linalg/bitarray.jl b/base/linalg/bitarray.jl index 992f55f03231d9..f06bfa24721958 100644 --- a/base/linalg/bitarray.jl +++ b/base/linalg/bitarray.jl @@ -69,11 +69,11 @@ end ## diff and gradient # TODO: this could be improved (is it worth it?) -gradient(F::BitVector) = gradient(bitunpack(F)) -gradient(F::BitVector, h::Real) = gradient(bitunpack(F), h) -gradient(F::Vector, h::BitVector) = gradient(F, bitunpack(h)) -gradient(F::BitVector, h::Vector) = gradient(bitunpack(F), h) -gradient(F::BitVector, h::BitVector) = gradient(bitunpack(F), bitunpack(h)) +gradient(F::BitVector) = gradient(Array(F)) +gradient(F::BitVector, h::Real) = gradient(Array(F), h) +gradient(F::Vector, h::BitVector) = gradient(F, Array(h)) +gradient(F::BitVector, h::Vector) = gradient(Array(F), h) +gradient(F::BitVector, h::BitVector) = gradient(Array(F), Array(h)) ## diag and related diff --git a/base/linalg/uniformscaling.jl b/base/linalg/uniformscaling.jl index 5d7a2d84adbfb2..b262aed34072bd 100644 --- a/base/linalg/uniformscaling.jl +++ b/base/linalg/uniformscaling.jl @@ -25,16 +25,16 @@ zero{T}(::Type{UniformScaling{T}}) = UniformScaling(zero(T)) zero{T}(J::UniformScaling{T}) = zero(UniformScaling{T}) (+)(J1::UniformScaling, J2::UniformScaling) = UniformScaling(J1.λ+J2.λ) -(+){T}(B::BitArray{2},J::UniformScaling{T}) = bitunpack(B) + J -(+)(J::UniformScaling, B::BitArray{2}) = J + bitunpack(B) +(+){T}(B::BitArray{2},J::UniformScaling{T}) = Array(B) + J +(+)(J::UniformScaling, B::BitArray{2}) = J + Array(B) (+)(J::UniformScaling, A::AbstractMatrix) = A + J (+)(J::UniformScaling, x::Number) = J.λ + x (+)(x::Number, J::UniformScaling) = x + J.λ (-)(J::UniformScaling) = UniformScaling(-J.λ) (-)(J1::UniformScaling, J2::UniformScaling) = UniformScaling(J1.λ-J2.λ) -(-)(B::BitArray{2}, J::UniformScaling) = bitunpack(B) - J -(-)(J::UniformScaling, B::BitArray{2}) = J - bitunpack(B) +(-)(B::BitArray{2}, J::UniformScaling) = Array(B) - J +(-)(J::UniformScaling, B::BitArray{2}) = J - Array(B) (-)(J::UniformScaling, x::Number) = J.λ - x (-)(x::Number, J::UniformScaling) = x - J.λ @@ -119,8 +119,8 @@ end inv(J::UniformScaling) = UniformScaling(inv(J.λ)) *(J1::UniformScaling, J2::UniformScaling) = UniformScaling(J1.λ*J2.λ) -*(B::BitArray{2}, J::UniformScaling) = *(bitunpack(B), J::UniformScaling) -*(J::UniformScaling, B::BitArray{2}) = *(J::UniformScaling, bitunpack(B)) +*(B::BitArray{2}, J::UniformScaling) = *(Array(B), J::UniformScaling) +*(J::UniformScaling, B::BitArray{2}) = *(J::UniformScaling, Array(B)) *(A::AbstractMatrix, J::UniformScaling) = J.λ == 1 ? A : J.λ*A *(J::UniformScaling, A::AbstractVecOrMat) = J.λ == 1 ? A : J.λ*A diff --git a/test/arrayops.jl b/test/arrayops.jl index 04fe4a1963bd90..9e7998cec00028 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -1264,21 +1264,21 @@ let x = fill(0.9, 1000) end #binary ops on bool arrays -A = bitunpack(trues(5)) +A = Array(trues(5)) @test A + true == [2,2,2,2,2] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test A + false == [1,1,1,1,1] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test true + A == [2,2,2,2,2] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test false + A == [1,1,1,1,1] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test A - true == [0,0,0,0,0] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test A - false == [1,1,1,1,1] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test true - A == [0,0,0,0,0] -A = bitunpack(trues(5)) +A = Array(trues(5)) @test false - A == [-1,-1,-1,-1,-1] # simple transposes diff --git a/test/bitarray.jl b/test/bitarray.jl index f4c9cddddb1e10..bd3dfb0450f74a 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -12,7 +12,7 @@ bitcheck(x) = true function check_bitop(ret_type, func, args...) r1 = func(args...) - r2 = func(map(x->(isa(x, BitArray) ? bitunpack(x) : x), args)...) + r2 = func(map(x->(isa(x, BitArray) ? Array(x) : x), args)...) @test isa(r1, ret_type) @test tc(r1, r2) @test isequal(r1, convert(ret_type, r2)) @@ -71,14 +71,14 @@ end for (sz,T) in allsizes b1 = rand!(falses(sz...)) - @test isequal(bitpack(bitunpack(b1)), b1) + @test isequal(BitArray(Array(b1)), b1) @test isequal(convert(Array{Float64,ndims(b1)}, b1), - convert(Array{Float64,ndims(b1)}, bitunpack(b1))) + convert(Array{Float64,ndims(b1)}, Array(b1))) @test isequal(convert(AbstractArray{Float64,ndims(b1)}, b1), - convert(AbstractArray{Float64,ndims(b1)}, bitunpack(b1))) + convert(AbstractArray{Float64,ndims(b1)}, Array(b1))) i1 = rand!(zeros(Bool, sz...), false:true) - @test isequal(bitunpack(bitpack(i1)), i1) + @test isequal(Array(BitArray(i1)), i1) end timesofar("conversions") @@ -90,8 +90,8 @@ b1 = bitrand(v1) @test isequal(fill!(b1, false), falses(size(b1))) for (sz,T) in allsizes - @test isequal(bitunpack(trues(sz...)), ones(Bool, sz...)) - @test isequal(bitunpack(falses(sz...)), zeros(Bool, sz...)) + @test isequal(Array(trues(sz...)), ones(Bool, sz...)) + @test isequal(Array(falses(sz...)), zeros(Bool, sz...)) b1 = rand!(falses(sz...)) @test isa(b1, T) @@ -101,7 +101,7 @@ for (sz,T) in allsizes @check_bit_operation size(b1) Tuple{Vararg{Int}} b2 = similar(b1) - u1 = bitunpack(b1) + u1 = Array(b1) @check_bit_operation copy!(b2, b1) T @check_bit_operation copy!(b2, u1) T end @@ -307,13 +307,13 @@ end # logical indexing b1 = bitrand(n1, n2) t1 = bitrand(n1, n2) -@test isequal(bitunpack(b1[t1]), bitunpack(b1)[t1]) -@test isequal(bitunpack(b1[t1]), bitunpack(b1)[bitunpack(t1)]) +@test isequal(Array(b1[t1]), Array(b1)[t1]) +@test isequal(Array(b1[t1]), Array(b1)[Array(t1)]) t1 = bitrand(n1) t2 = bitrand(n2) -@test isequal(bitunpack(b1[t1, t2]), bitunpack(b1)[t1, t2]) -@test isequal(bitunpack(b1[t1, t2]), bitunpack(b1)[bitunpack(t1), bitunpack(t2)]) +@test isequal(Array(b1[t1, t2]), Array(b1)[t1, t2]) +@test isequal(Array(b1[t1, t2]), Array(b1)[Array(t1), Array(t2)]) b1 = bitrand(n1, n2) @@ -350,17 +350,17 @@ for m = 1 : v1 x = rand(Bool) push!(b1, x) push!(i1, x) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end for m1 = 0 : v1 for m2 = [0, 1, 63, 64, 65, 127, 128, 129] b1 = bitrand(m1) b2 = bitrand(m2) - i1 = bitunpack(b1) - i2 = bitunpack(b2) - @test isequal(bitunpack(append!(b1, b2)), append!(i1, i2)) - @test isequal(bitunpack(append!(b1, i2)), append!(i1, b2)) + i1 = Array(b1) + i2 = Array(b2) + @test isequal(Array(append!(b1, b2)), append!(i1, i2)) + @test isequal(Array(append!(b1, i2)), append!(i1, b2)) end end @@ -368,20 +368,20 @@ for m1 = 0 : v1 for m2 = [0, 1, 63, 64, 65, 127, 128, 129] b1 = bitrand(m1) b2 = bitrand(m2) - i1 = bitunpack(b1) - i2 = bitunpack(b2) - @test isequal(bitunpack(prepend!(b1, b2)), prepend!(i1, i2)) - @test isequal(bitunpack(prepend!(b1, i2)), prepend!(i1, b2)) + i1 = Array(b1) + i2 = Array(b2) + @test isequal(Array(prepend!(b1, b2)), prepend!(i1, i2)) + @test isequal(Array(prepend!(b1, i2)), prepend!(i1, b2)) end end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m = 1 : v1 jb = pop!(b1) ji = pop!(i1) @test jb == ji - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end @test length(b1) == 0 @@ -392,59 +392,59 @@ for m = 1 : v1 x = rand(Bool) unshift!(b1, x) unshift!(i1, x) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m = 1 : v1 jb = shift!(b1) ji = shift!(i1) @test jb == ji - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end @test length(b1) == 0 b1 = BitArray(0) @test_throws BoundsError insert!(b1, 2, false) @test_throws BoundsError insert!(b1, 0, false) -i1 = bitunpack(b1) +i1 = Array(b1) for m = 1 : v1 j = rand(1:m) x = rand(Bool) @test insert!(b1, j, x) === b1 insert!(i1, j, x) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for j in [63, 64, 65, 127, 128, 129, 191, 192, 193] x = rand(0:1) @test insert!(b1, j, x) === b1 insert!(i1, j, x) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m = v1 : -1 : 1 j = rand(1:m) b = splice!(b1, j) i = splice!(i1, j) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) @test b == i end @test length(b1) == 0 b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m = v1 : -1 : 1 j = rand(1:m) deleteat!(b1, j) deleteat!(i1, j) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end @test length(b1) == 0 b1 = bitrand(v1) @@ -452,109 +452,109 @@ b1 = bitrand(v1) @test_throws BoundsError deleteat!(b1,[1 length(b1)+1]) b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for j in [63, 64, 65, 127, 128, 129, 191, 192, 193] b = splice!(b1, j) i = splice!(i1, j) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) @test b == i end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for j in [63, 64, 65, 127, 128, 129, 191, 192, 193] deleteat!(b1, j) deleteat!(i1, j) - @test isequal(bitunpack(b1), i1) + @test isequal(Array(b1), i1) end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m1 = 1 : v1 for m2 = m1 : v1 b2 = copy(b1) i2 = copy(i1) b = splice!(b2, m1:m2) i = splice!(i2, m1:m2) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i end end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m1 = 1 : v1 for m2 = m1 : v1 b2 = copy(b1) i2 = copy(i1) deleteat!(b2, m1:m2) deleteat!(i2, m1:m2) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) end end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m1 = 1 : v1 + 1 for m2 = m1 - 1 : v1 for v2::Int = [0, 1, 63, 64, 65, 127, 128, 129, 191, 192, 193, rand(1:v1)] b2 = copy(b1) i2 = copy(i1) b3 = bitrand(v2) - i3 = bitunpack(b3) + i3 = Array(b3) b = splice!(b2, m1:m2, b3) i = splice!(i2, m1:m2, i3) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i b2 = copy(b1) i2 = copy(i1) i3 = map(Int,bitrand(v2)) b = splice!(b2, m1:m2, i3) i = splice!(i2, m1:m2, i3) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i b2 = copy(b1) i2 = copy(i1) i3 = [j => rand(0:1) for j = 1:v2] b = splice!(b2, m1:m2, values(i3)) i = splice!(i2, m1:m2, values(i3)) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i end end end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m1 = 1 : v1 for v2 = [0, 1, 63, 64, 65, 127, 128, 129, 191, 192, 193, rand(1:v1)] b2 = copy(b1) i2 = copy(i1) b3 = bitrand(v2) - i3 = bitunpack(b3) + i3 = Array(b3) b = splice!(b2, m1, b3) i = splice!(i2, m1, i3) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i b2 = copy(b1) i2 = copy(i1) i3 = map(Int,bitrand(v2)) b = splice!(b2, m1:m2, i3) i = splice!(i2, m1:m2, i3) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i b2 = copy(b1) i2 = copy(i1) i3 = [j => rand(0:1) for j = 1:v2] b = splice!(b2, m1:m2, values(i3)) i = splice!(i2, m1:m2, values(i3)) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) @test b == i end end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) for m1 = 1 : v1 - 1 for m2 = m1 + 1 : v1 locs = bitrand(m2-m1+1) @@ -563,15 +563,15 @@ for m1 = 1 : v1 - 1 i2 = copy(i1) deleteat!(b2, m) deleteat!(i2, m) - @test isequal(bitunpack(b2), i2) + @test isequal(Array(b2), i2) end end b1 = bitrand(v1) -i1 = bitunpack(b1) +i1 = Array(b1) empty!(b1) empty!(i1) -@test isequal(bitunpack(b1), i1) +@test isequal(Array(b1), i1) timesofar("dequeue") @@ -613,10 +613,10 @@ b2 = bitrand(n1, n2) b2 = trues(n1, n2) @check_bit_operation div(b1, b2) BitMatrix @check_bit_operation mod(b1, b2) BitMatrix -@check_bit_operation div(b1,bitunpack(b2)) BitMatrix -@check_bit_operation mod(b1,bitunpack(b2)) BitMatrix -@check_bit_operation div(bitunpack(b1),b2) BitMatrix -@check_bit_operation mod(bitunpack(b1),b2) BitMatrix +@check_bit_operation div(b1,Array(b2)) BitMatrix +@check_bit_operation mod(b1,Array(b2)) BitMatrix +@check_bit_operation div(Array(b1),b2) BitMatrix +@check_bit_operation mod(Array(b1),b2) BitMatrix while true global b1 @@ -742,7 +742,7 @@ f2 = Float64(i2) ci2 = complex(i2) cu2 = complex(u2) cf2 = complex(f2) -b2 = bitunpack(bitrand(n1,n2)) +b2 = Array(bitrand(n1,n2)) @check_bit_operation (&)(b1, true) BitMatrix @check_bit_operation (&)(b1, false) BitMatrix @@ -1276,7 +1276,7 @@ timesofar("linalg") @test sizeof(BitArray(65)) == 16 #one -@test bitunpack(one(BitMatrix(2,2))) == eye(2,2) +@test Array(one(BitMatrix(2,2))) == eye(2,2) @test_throws DimensionMismatch one(BitMatrix(2,3)) #reshape @@ -1309,35 +1309,35 @@ a = falses(6) @test findmax(a) == (false,1) a = trues(6) @test findmin(a) == (true,1) -a = bitpack([1,0,1,1,0]) +a = BitArray([1,0,1,1,0]) @test findmin(a) == (false,2) @test findmax(a) == (true,1) -a = bitpack([0,0,1,1,0]) +a = BitArray([0,0,1,1,0]) @test findmin(a) == (false,1) @test findmax(a) == (true,3) #qr and svd A = bitrand(10,10) -uA = bitunpack(A) +uA = Array(A) @test svd(A) == svd(uA) @test qr(A) == qr(uA) #gradient A = bitrand(10) -fA = bitunpack(A) +fA = Array(A) @test gradient(A) == gradient(fA) @test gradient(A,1.0) == gradient(fA,1.0) #diag and diagm v = bitrand(10) -uv = bitunpack(v) -@test bitunpack(diagm(v)) == diagm(uv) +uv = Array(v) +@test Array(diagm(v)) == diagm(uv) v = bitrand(10,2) -uv = bitunpack(v) +uv = Array(v) @test_throws DimensionMismatch diagm(v) B = bitrand(10,10) -uB = bitunpack(B) -@test diag(uB) == bitunpack(diag(B)) +uB = Array(B) +@test diag(uB) == Array(diag(B)) diff --git a/test/broadcast.jl b/test/broadcast.jl index 1dd30712a3c039..565160672b5705 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -29,7 +29,7 @@ function as_sub{T}(x::AbstractArray{T,3}) y end -bittest(f::Function, ewf::Function, a...) = (@test ewf(a...) == bitpack(broadcast(f, a...))) +bittest(f::Function, ewf::Function, a...) = (@test ewf(a...) == BitArray(broadcast(f, a...))) n1 = 21 n2 = 32 n3 = 17 @@ -61,9 +61,9 @@ for arr in (identity, as_sub) @test arr([1 2]) ./ arr([3, 4]) == [1/3 2/3; 1/4 2/4] @test arr([1 2]) .\ arr([3, 4]) == [3 1.5; 4 2] @test arr([3 4]) .^ arr([1, 2]) == [3 4; 9 16] - @test arr(bitpack([true false])) .* arr(bitpack([true, true])) == [true false; true false] - @test arr(bitpack([true false])) .^ arr(bitpack([false, true])) == [true true; true false] - @test arr(bitpack([true false])) .^ arr([0, 3]) == [true true; true false] + @test arr(BitArray([true false])) .* arr(BitArray([true, true])) == [true false; true false] + @test arr(BitArray([true false])) .^ arr(BitArray([false, true])) == [true true; true false] + @test arr(BitArray([true false])) .^ arr([0, 3]) == [true true; true false] M = arr([11 12; 21 22]) @test broadcast_getindex(M, eye(Int, 2).+1,arr([1, 2])) == [21 11; 12 22] diff --git a/test/hashing.jl b/test/hashing.jl index 3df644e7d7bccf..9a28d1c37388ff 100644 --- a/test/hashing.jl +++ b/test/hashing.jl @@ -59,7 +59,7 @@ end # hashing collections (e.g. issue #6870) vals = Any[ [1,2,3,4], [1 3;2 4], Any[1,2,3,4], [1,3,2,4], - [1,0], [true,false], bitpack([true,false]), + [1,0], [true,false], BitArray([true,false]), Set([1,2,3,4]), Set([1:10;]), # these lead to different key orders Set([7,9,4,10,2,3,5,8,6,1]), # diff --git a/test/reduce.jl b/test/reduce.jl index 3e4f0e3e8ec36a..723a85c39037dc 100644 --- a/test/reduce.jl +++ b/test/reduce.jl @@ -118,7 +118,7 @@ end @test prod(1:big(16)) == big(20922789888000) @test prod(big(typemax(Int64)):big(typemax(Int64))+16) == parse(BigInt,"25300281663413827620486300433089141956148633919452440329174083959168114253708467653081909888307573358090001734956158476311046124934597861626299416732205795533726326734482449215730132757595422510465791525610410023802664753402501982524443370512346073948799084936298007821432734720004795146875180123558814648586972474376192000") -@test typeof(prod(bitunpack(trues(10)))) == Bool +@test typeof(prod(Array(trues(10)))) == Bool # check type-stability prod2(itr) = invoke(prod, Tuple{Any}, itr)