Skip to content

Commit

Permalink
remove _oldstyle_array_vcat_
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Sep 11, 2015
1 parent 042971a commit c3fd3d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 64 deletions.
41 changes: 5 additions & 36 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,11 @@ typealias RangeIndex Union{Int, Range{Int}, UnitRange{Int}, Colon}
vect() = Array(Any, 0)
vect{T}(X::T...) = T[ X[i] for i=1:length(X) ]

const _oldstyle_array_vcat_ = true

if _oldstyle_array_vcat_
function oldstyle_vcat_warning(n::Int)
if n == 1
before = "[a]"
after = "collect(a)"
elseif n == 2
before = "[a,b]"
after = "[a;b]"
else
before = "[a,b,...]"
after = "[a;b;...]"
end
depwarn("$before concatenation is deprecated; use $after instead", :vect)
end
function vect(A::AbstractArray...)
oldstyle_vcat_warning(length(A))
vcat(A...)
end
function vect(X...)
for a in X
if typeof(a) <: AbstractArray
oldstyle_vcat_warning(length(X))
break
end
end
vcat(X...)
end
else
function vect(X...)
T = promote_typeof(X...)
#T[ X[i] for i=1:length(X) ]
# TODO: this is currently much faster. should figure out why. not clear.
copy!(Array(T,length(X)), X)
end
function vect(X...)
T = promote_typeof(X...)
#T[ X[i] for i=1:length(X) ]
# TODO: this is currently much faster. should figure out why. not clear.
copy!(Array(T,length(X)), X)
end

size{T,n}(t::AbstractArray{T,n}, d) = d <= n ? size(t)[d] : 1
Expand Down
19 changes: 0 additions & 19 deletions test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,24 +434,6 @@ function test_UInt_indexing(::Type{TestAbstractArray})
end
end

function test_vcat_depwarn(::Type{TestAbstractArray})
if (Base.JLOptions()).depwarn > 1
@test_throws ErrorException [1:10]
@test_throws ErrorException [[1, 2], [3, 4]]
@test_throws ErrorException [[1, 2], [3, 4], [5, 6]]
else
olderr = STDERR
try
rd, wr = redirect_stderr()
@test [1:10] == [1:10...]
@test [[1, 2], [3, 4]] == [1, 2, 3, 4]
@test [[1, 2], [3, 4], [5, 6]] == [1, 2, 3, 4, 5, 6]
finally
redirect_stderr(olderr)
end
end
end

#----- run tests -------------------------------------------------------------#

for T in (T24Linear, TSlow), shape in ((24,), (2, 12), (2,3,4), (1,2,3,4), (4,3,2,1))
Expand All @@ -470,4 +452,3 @@ test_ind2sub(TestAbstractArray)
test_map(TestAbstractArray)
test_map_promote(TestAbstractArray)
test_UInt_indexing(TestAbstractArray)
test_vcat_depwarn(TestAbstractArray)
16 changes: 7 additions & 9 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,13 @@ for i = 1:length(X) @test X[i] === Y[i] end

_array_equiv(a,b) = eltype(a) == eltype(b) && a == b
@test _array_equiv(UInt8[1:3;4], [0x1,0x2,0x3,0x4])
if !Base._oldstyle_array_vcat_
@test_throws MethodError UInt8[1:3]
@test_throws MethodError UInt8[1:3,]
@test_throws MethodError UInt8[1:3,4:6]
a = Array(UnitRange{Int},1); a[1] = 1:3
@test _array_equiv([1:3,], a)
a = Array(UnitRange{Int},2); a[1] = 1:3; a[2] = 4:6
@test _array_equiv([1:3,4:6], a)
end
@test_throws MethodError UInt8[1:3]
@test_throws MethodError UInt8[1:3,]
@test_throws MethodError UInt8[1:3,4:6]
a = Array(UnitRange{Int},1); a[1] = 1:3
@test _array_equiv([1:3,], a)
a = Array(UnitRange{Int},2); a[1] = 1:3; a[2] = 4:6
@test _array_equiv([1:3,4:6], a)

# typed hvcat
let X = Float64[1 2 3; 4 5 6]
Expand Down

0 comments on commit c3fd3d4

Please sign in to comment.