From a4e3cd29897a6853faf9f1ab0dfb657cbc521cd1 Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Thu, 23 Jun 2016 12:36:43 -0700 Subject: [PATCH] Replace full(X) calls with convert(Array, X) elsewhere in base/ (outside base/sparse and base/linalg), apart from the no-op fallback for `AbstractArray`s in abstractarray.jl. --- base/abstractarray.jl | 10 +++++----- base/test.jl | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 3e82aeb2245fa..0497852f798ff 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -896,7 +896,7 @@ function typed_vcat{T}(::Type{T}, V::AbstractVector...) for Vk in V n += length(Vk) end - a = similar(full(V[1]), T, n) + a = similar(convert(Array, V[1]), T, n) pos = 1 for k=1:length(V) Vk = V[k] @@ -924,7 +924,7 @@ function typed_hcat{T}(::Type{T}, A::AbstractVecOrMat...) nd = ndims(Aj) ncols += (nd==2 ? size(Aj,2) : 1) end - B = similar(full(A[1]), T, nrows, ncols) + B = similar(convert(Array, A[1]), T, nrows, ncols) pos = 1 if dense for k=1:nargs @@ -956,7 +956,7 @@ function typed_vcat{T}(::Type{T}, A::AbstractMatrix...) throw(ArgumentError("number of columns of each array must match (got $(map(x->size(x,2), A)))")) end end - B = similar(full(A[1]), T, nrows, ncols) + B = similar(convert(Array, A[1]), T, nrows, ncols) pos = 1 for k=1:nargs Ak = A[k] @@ -1003,7 +1003,7 @@ function cat_t(catdims, typeC::Type, X...) end end - C = similar(isa(X[1],AbstractArray) ? full(X[1]) : [X[1]], typeC, tuple(dimsC...)) + C = similar(isa(X[1],AbstractArray) ? convert(Array, X[1]) : [X[1]], typeC, tuple(dimsC...)) if length(catdims)>1 fill!(C,0) end @@ -1075,7 +1075,7 @@ function typed_hvcat{T}(::Type{T}, rows::Tuple{Vararg{Int}}, as::AbstractMatrix. a += rows[i] end - out = similar(full(as[1]), T, nr, nc) + out = similar(convert(Array, as[1]), T, nr, nc) a = 1 r = 1 diff --git a/base/test.jl b/base/test.jl index 2681d48ee573a..1411a28010799 100644 --- a/base/test.jl +++ b/base/test.jl @@ -817,7 +817,7 @@ end approx_full(x::AbstractArray) = x approx_full(x::Number) = x -approx_full(x) = full(x) +approx_full(x) = convert(Array, x) function test_approx_eq(va, vb, Eps, astr, bstr) va = approx_full(va)