Skip to content

Commit

Permalink
Updated messages based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottPJones committed Jul 8, 2015
1 parent 4a725da commit abd7abe
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ similar( a::AbstractArray, T, dims::Dims) = Array(T, dims)

function reshape(a::AbstractArray, dims::Dims)
if prod(dims) != length(a)
throw(ArgumentError("dimensions must be consistent with array size"))
throw(ArgumentError("dimensions must be consistent with array size (expected $(length(a)), got $(prod(dims)))"))
end
copy!(similar(a, dims), a)
end
Expand Down Expand Up @@ -326,8 +326,8 @@ function copy!{R,S}(B::AbstractVecOrMat{R}, ir_dest::Range{Int}, jr_dest::Range{
A::AbstractVecOrMat{S}, ir_src::Range{Int}, jr_src::Range{Int})
if length(ir_dest) != length(ir_src) || length(jr_dest) != length(jr_src)
length(ir_dest) != length(ir_src) &&
throw(ArgumentError("source ($(length(ir_src))) and destination ($(length(ir_dest))) must have same size"))
throw(ArgumentError("source ($(length(jr_src))) and destination ($(length(jr_dest))) must have same size"))
throw(ArgumentError("source and destination must have same size (got $(length(ir_src)) and $(length(ir_dest)))"))
throw(ArgumentError("source and destination must have same size (got $(length(jr_src)) and $(length(jr_dest)))"))
end
checkbounds(B, ir_dest, jr_dest)
checkbounds(A, ir_src, jr_src)
Expand All @@ -347,8 +347,8 @@ function copy_transpose!{R,S}(B::AbstractVecOrMat{R}, ir_dest::Range{Int}, jr_de
A::AbstractVecOrMat{S}, ir_src::Range{Int}, jr_src::Range{Int})
if length(ir_dest) != length(jr_src) || length(jr_dest) != length(ir_src)
length(ir_dest) != length(jr_src) &&
throw(ArgumentError("source ($(length(ir_src))) and destination ($(length(ir_dest))) must have same size"))
throw(ArgumentError("source ($(length(jr_src))) and destination ($(length(jr_dest))) must have same size"))
throw(ArgumentError("source and destination must have same size (got $(length(jr_src)) and $(length(ir_dest)))"))
throw(ArgumentError("source and destination must have same size (got $(length(ir_src)) and $(length(jr_dest)))"))
end
checkbounds(B, ir_dest, jr_dest)
checkbounds(A, ir_src, jr_src)
Expand Down Expand Up @@ -710,7 +710,7 @@ function hcat{T}(A::AbstractVecOrMat{T}...)
for j = 1:nargs
Aj = A[j]
if size(Aj, 1) != nrows
throw(ArgumentError("number of rows of A[$j] ($(size(Aj,1))) must match $nrows"))
throw(ArgumentError("number of rows of arrays must match (got $(map(x->size(x,1), A)))"))
end
dense &= isa(Aj,Array)
nd = ndims(Aj)
Expand Down Expand Up @@ -742,7 +742,7 @@ function vcat{T}(A::AbstractMatrix{T}...)
ncols = size(A[1], 2)
for j = 2:nargs
if size(A[j], 2) != ncols
throw(ArgumentError("number of columns of A[$j] ($(size(A[j],2))) must match $ncols"))
throw(ArgumentError("number of columns of arrays must match (got $(map(x->size(x,2), A)))"))
end
end
B = similar(full(A[1]), nrows, ncols)
Expand Down Expand Up @@ -783,7 +783,7 @@ function cat_t(catdims, typeC::Type, X...)
currentdim = (d <= ndimsX[i] ? size(X[i],d) : 1)
if dims2cat[d] == 0
dimsC[d] == currentdim ||
throw(DimensionMismatch("mismatch in dimension $(d)"))
throw(DimensionMismatch("mismatch in dimension $(d) (expected $currentdim, got $(dimsC[d]))"))
else
dimsC[d] += currentdim
catsizes[i,dims2cat[d]] = currentdim
Expand Down Expand Up @@ -840,7 +840,7 @@ function hvcat(nbc::Integer, as...)
# nbc = # of block columns
n = length(as)
mod(n,nbc) != 0 &&
throw(ArgumentError("all rows must have the same number of block columns ($nbc)"))
throw(ArgumentError("number of arrays $n is not a multiple of the requested number of block columns $nbc"))
nbr = div(n,nbc)
hvcat(ntuple(i->nbc, nbr), as...)
end
Expand Down Expand Up @@ -871,16 +871,16 @@ function hvcat{T}(rows::Tuple{Vararg{Int}}, as::AbstractMatrix{T}...)
Aj = as[a+j-1]
szj = size(Aj,2)
if size(Aj,1) != szi
throw(ArgumentError("mismatched height in block row $(i)"))
throw(ArgumentError("mismatched height in block row $(i) (expected $szi, got $(size(Aj,1)))"))
end
if c-1+szj > nc
throw(ArgumentError("block row $(i) has mismatched number of columns: $(c-1+szj) $nc"))
throw(ArgumentError("block row $(i) has mismatched number of columns (expected $nc, got $(c-1+szj))"))
end
out[r:r-1+szi, c:c-1+szj] = Aj
c += szj
end
if c != nc+1
throw(ArgumentError("block row $(i) has mismatched number of columns $(c-1) $nc"))
throw(ArgumentError("block row $(i) has mismatched number of columns (expected $nc, got $(c-1))"))
end
r += szi
a += rows[i]
Expand All @@ -896,12 +896,12 @@ function hvcat{T<:Number}(rows::Tuple{Vararg{Int}}, xs::T...)

a = Array(T, nr, nc)
if length(a) != length(xs)
throw(ArgumentError("argument count does not match specified shape $(length(a)) != $(length(xs))"))
throw(ArgumentError("argument count does not match specified shape (expected $(length(a)), got $(length(xs)))"))
end
k = 1
@inbounds for i=1:nr
if nc != rows[i]
throw(ArgumentError("row $(i) has mismatched number of columns $(rows[i]) != $nc"))
throw(ArgumentError("row $(i) has mismatched number of columns (expected $nc, got $(rows[i]))"))
end
for j=1:nc
a[i,j] = xs[k]
Expand All @@ -928,7 +928,7 @@ function typed_hvcat(T::Type, rows::Tuple{Vararg{Int}}, xs::Number...)
nc = rows[1]
for i = 2:nr
if nc != rows[i]
throw(ArgumentError("row $(i) has mismatched number of columns $(rows[i]) != $nc"))
throw(ArgumentError("row $(i) has mismatched number of columns (expected $nc, got $(rows[i]))"))
end
end
len = length(xs)
Expand Down

0 comments on commit abd7abe

Please sign in to comment.