Skip to content

Commit

Permalink
bring more error messages up to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 19, 2013
1 parent de3dcdc commit 704b852
Show file tree
Hide file tree
Showing 40 changed files with 186 additions and 189 deletions.
5 changes: 2 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,7 @@ function cat(catdim::Integer, X...)
len = d <= ndimsX[1] ? dimsX[1][d] : 1
for i = 2:nargs
if len != (d <= ndimsX[i] ? dimsX[i][d] : 1)
error("Dimension mismatch on dimension ", d)
#error("lala $d")
error("mismatch in dimension ", d)
end
end
end
Expand Down Expand Up @@ -876,7 +875,7 @@ function cat_t(catdim::Integer, typeC, A::AbstractArray...)
len = d <= ndimsA[1] ? dimsA[1][d] : 1
for i = 2:nargs
if len != (d <= ndimsA[i] ? dimsA[i][d] : 1)
error("dimension mismatch on dimension ", d)
error("mismatch in dimension ", d)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ end

function pop!(B::BitVector)
if isempty(B)
error("BitArray must not be empty")
error("argument must not be empty")
end
item = B[end]
B[end] = false
Expand Down Expand Up @@ -993,7 +993,7 @@ end

function shift!(B::BitVector)
if isempty(B)
error("BitArray must not be empty")
error("argument must not be empty")
end
@inbounds begin
item = B[1]
Expand Down Expand Up @@ -2309,7 +2309,7 @@ function cat(catdim::Integer, X::Union(BitArray, Integer)...)
len = d <= ndimsX[1] ? dimsX[1][d] : 1
for i = 2:nargs
if len != (d <= ndimsX[i] ? dimsX[i][d] : 1)
error("Dimension mismatch on dimension ", d)
error("mismatch in dimension ", d)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion base/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function invperm(a::AbstractVector)
for i = 1:n
j = a[i]
((1 <= j <= n) && b[j] == 0) ||
error("input is not a permutation")
error("argument is not a permutation")
b[j] = i
end
b
Expand Down
2 changes: 1 addition & 1 deletion base/darray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end

function reshape{T,S<:Array}(A::DArray{T,1,S}, d::Dims)
if prod(d) != length(A)
error("Dimensions must be consistent with array size.")
error("dimensions must be consistent with array size")
end
DArray(d) do I
sz = map(length,I)
Expand Down
8 changes: 4 additions & 4 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function mkpath(path::String, mode::Unsigned=0o777)
mkdir(path)
end

mkdir(path::String, mode::Signed) = error("mkdir: mode must be an unsigned integer -- perhaps 0o$mode?")
mkpath(path::String, mode::Signed) = error("mkpath: mode must be an unsigned integer -- perhaps 0o$mode?")
mkdir(path::String, mode::Signed) = error("mode must be an unsigned integer; try 0o$mode")
mkpath(path::String, mode::Signed) = error("mode must be an unsigned integer; try 0o$mode")

function rmdir(path::String)
@unix_only ret = ccall(:rmdir, Int32, (Ptr{Uint8},), bytestring(path))
Expand Down Expand Up @@ -151,7 +151,7 @@ function download(url::String, filename::String)
elseif downloadcmd == :fetch
run(`fetch -f $filename $url`)
else
error("No download agent available; install curl, wget, or fetch.")
error("no download agent available; install curl, wget, or fetch")
end
filename
end
Expand All @@ -169,7 +169,7 @@ function readdir(path::String)
bytestring(path), uv_readdir_req)

if file_count < 0
error("Unable to read directory $path.")
error("unable to read directory $path")
end

# The list of dir entries is returned as a contiguous sequence of null-terminated
Expand Down
10 changes: 5 additions & 5 deletions base/fs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open(f::String,flags) = open(f,flags,0)

function close(f::File)
if !f.open
error("File is already closed")
error("file is already closed")
end
err = ccall(:jl_fs_close, Int32, (Int32,), f.handle)
uv_error("close",err)
Expand All @@ -93,7 +93,7 @@ function unlink(p::String)
end
function unlink(f::File)
if isempty(f.path)
error("No path associated with this file")
error("no path associated with this file")
end
if f.open
close(f)
Expand All @@ -104,7 +104,7 @@ end

function write(f::File, buf::Ptr{Uint8}, len::Integer, offset::Integer=-1)
if !f.open
error("File is not open")
error("file is not open")
end
err = ccall(:jl_fs_write, Int32, (Int32, Ptr{Uint8}, Csize_t, Csize_t),
f.handle, buf, len, offset)
Expand All @@ -114,7 +114,7 @@ end

function write(f::File, c::Uint8)
if !f.open
error("File is not open")
error("file is not open")
end
err = ccall(:jl_fs_write_byte, Int32, (Int32, Cchar), f.handle, c)
uv_error("write",err)
Expand All @@ -140,7 +140,7 @@ end

function read(f::File, ::Type{Uint8})
if !f.open
error("File is not open")
error("file is not open")
end
ret = ccall(:jl_fs_read_byte, Int32, (Int32,), f.handle)
uv_error("read", ret)
Expand Down
4 changes: 2 additions & 2 deletions base/intset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ isempty(s::IntSet) =
function first(s::IntSet)
n = next(s,0)[1]
if n >= s.limit
error("first: set is empty")
error("set must be non-empty")
end
return n
end
Expand All @@ -160,7 +160,7 @@ function last(s::IntSet)
end
end
end
error("last: set has no last element")
error("set has no last element")
end

length(s::IntSet) = int(ccall(:bitvector_count, Uint64, (Ptr{Uint32}, Uint64, Uint64), s.bits, 0, s.limit)) +
Expand Down
6 changes: 3 additions & 3 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ write(s::IOStream, b::Uint8) = int(ccall(:jl_putc, Int32, (Uint8, Ptr{Void}), b,
function write{T}(s::IOStream, a::Array{T})
if isbits(T)
if isreadonly(s)
error("Cannot write to a read-only IOStream")
error("attempt to write to a read-only IOStream")
end
int(ccall(:ios_write, Uint, (Ptr{Void}, Ptr{Void}, Uint),
s.ios, a, length(a)*sizeof(T)))
Expand All @@ -363,7 +363,7 @@ end

function write(s::IOStream, p::Ptr, nb::Integer)
if isreadonly(s)
error("Cannot write to a read-only IOStream")
error("attempt to write to a read-only IOStream")
end
int(ccall(:ios_write, Uint, (Ptr{Void}, Ptr{Void}, Uint), s.ios, p, nb))
end
Expand Down Expand Up @@ -410,7 +410,7 @@ end

function write(s::IOStream, c::Char)
if isreadonly(s)
error("Cannot write to a read-only IOStream")
error("attempt to write to a read-only IOStream")
end
int(ccall(:ios_pututf8, Int32, (Ptr{Void}, Char), s.ios, c))
end
Expand Down
4 changes: 2 additions & 2 deletions base/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function read_sub{T}(from::IOBuffer, a::Array{T}, offs, nel)
throw(BoundsError())
end
if !isbits(T)
error("Read from IOBuffer only supports bits types or arrays of bits types; got "*string(T)*".")
error("read from IOBuffer only supports bits types or arrays of bits types; got "*string(T))
end
read(from, pointer(a, offs), nel*sizeof(T))
return a
Expand Down Expand Up @@ -207,7 +207,7 @@ function write_sub{T}(to::IOBuffer, a::Array{T}, offs, nel)
throw(BoundsError())
end
if !isbits(T)
error("Write to IOBuffer only supports bits types or arrays of bits types; got "*string(T)*".")
error("write to IOBuffer only supports bits types or arrays of bits types; got "*string(T))
end
write(to, pointer(a,offs), nel*sizeof(T))
end
Expand Down
6 changes: 3 additions & 3 deletions base/linalg/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function eigs(A;nev::Integer=6, ncv::Integer=20, which::ASCIIString="LM",
ritzvec::Bool=true, complexOP::Bool=false)

(m, n) = size(A)
if m != n; error("Input must be square"); end
if m != n; error("matrix must be square"); end
if n <= 6 && nev > n-1; nev = n-1; end
ncv = blas_int(min(max(2*nev+2, ncv), n))

Expand All @@ -16,8 +16,8 @@ function eigs(A;nev::Integer=6, ncv::Integer=20, which::ASCIIString="LM",
cmplx = T<:Complex
bmat = "I"
if !isempty(v0)
if length(v0)!=n; error("Starting vector must have length $n"); end
if eltype(v0)!=T; error("Starting vector must have eltype $T"); end
if length(v0)!=n; error("starting vector must have length $n"); end
if eltype(v0)!=T; error("starting vector must have eltype $T"); end
else
v0=zeros(T,(0,))
end
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/arpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function aupd_wrapper(T, linop::Function, n::Integer,
naupd(ido, bmat, n, which, nev, TOL, resid, ncv, v, n,
iparam, ipntr, workd, workl, lworkl, info)
end
if info[1] == 3; warn("Try eigs/svds with a larger value for ncv."); end
if info[1] == 1; warn("Maximum number of iterations taken. Check nconv for number of converged eigenvalues."); end
if info[1] == 3; warn("try eigs/svds with a larger value for ncv"); end
if info[1] == 1; warn("maximum number of iterations reached; check nconv for number of converged eigenvalues"); end
if info[1] < 0; throw(ARPACKException(info[1])); end
if (ido[1] != -1 && ido[1] != 1); break; end
workd[ipntr[2]+zernm1] = linop(getindex(workd, ipntr[1]+zernm1))
Expand Down
6 changes: 3 additions & 3 deletions base/linalg/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end
function diagm(v::Union(BitVector,BitMatrix))
if isa(v, BitMatrix)
if (size(v,1) != 1 && size(v,2) != 1)
error("Input should be nx1 or 1xn")
error("argument should be nx1 or 1xn")
end
end

Expand Down Expand Up @@ -224,7 +224,7 @@ end

function findmax(a::BitArray)
if length(a) == 0
error("findmax: array is empty")
error("array must be non-empty")
end
m = false
mi = 1
Expand All @@ -244,7 +244,7 @@ end

function findmin(a::BitArray)
if length(a) == 0
error("findmin: array is empty")
error("array must be non-empty")
end
m = true
mi = 1
Expand Down
6 changes: 3 additions & 3 deletions base/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ for (fname, elty) in ((:daxpy_,:Float64),
end
function axpy!{T,Ta<:Number}(alpha::Ta, x::Array{T}, y::Array{T})
if length(x) != length(y)
error("Inputs should be of the same length")
error("arguments must be of the same length")
end
return axpy!(length(x), convert(T,alpha), x, 1, y, 1)
end
Expand All @@ -175,7 +175,7 @@ function axpy!{T,Ta<:Number,Ti<:Integer}(alpha::Ta, x::Array{T}, rx::Union(Range
y::Array{T}, ry::Union(Range1{Ti},Range{Ti}))

if length(rx) != length(ry)
error("Ranges should be of the same length")
error("ranges must be of the same length")
end

if minimum(rx) < 1 || maximum(rx) > length(x) || minimum(ry) < 1 || maximum(ry) > length(y)
Expand Down Expand Up @@ -576,7 +576,7 @@ function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union(Range1{Ti}
throw(BoundsError())
end
if length(rdest) != length(rsrc)
error("Ranges must be of the same length")
error("ranges must be of the same length")
end
BLAS.blascopy!(length(rsrc), pointer(src)+(first(rsrc)-1)*sizeof(T), step(rsrc),
pointer(dest)+(first(rdest)-1)*sizeof(T), step(rdest))
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function bkfact!{T<:BlasReal}(A::StridedMatrix{T}, uplo::Symbol)
end
function bkfact!{T<:BlasReal}(A::StridedMatrix{T}, uplo::Symbol, symmetric::Bool)
if symmetric return bkfact!(A, uplo) end
error("The Bunch-Kaufman decomposition is only valid for symmetric matrices")
error("the Bunch-Kaufman decomposition is only valid for symmetric matrices")
end
function bkfact!{T<:BlasComplex}(A::StridedMatrix{T}, uplo::Symbol, symmetric::Bool)
if symmetric
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ for Ti in (:Int32,:Int64)
nc = trans ? m : n
nr = trans ? n : m
if nc != size(X,1)
error("Incompatible dimensions, $nc and $(size(X,1)), in chm_sdmult")
error("incompatible dimensions, $nc and $(size(X,1)), in chm_sdmult")
end
aa = float64([alpha, 0.])
bb = float64([beta, 0.])
Expand Down Expand Up @@ -977,7 +977,7 @@ function findnz{Tv,Ti}(A::CholmodSparse{Tv,Ti})
ipos += 1
count += 1
else
println("Warning: sparse matrix contains explicitly stored zeros.")
println("warning: sparse matrix contains explicitly stored zeros")
end
end
ind = ind[1:count] # ind is the indices of nonzeros in A.nzval
Expand Down
6 changes: 3 additions & 3 deletions base/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ rref(x::Number) = one(x)
## "Functions of Matrices: Theory and Computation", SIAM
function expm!{T<:BlasFloat}(A::StridedMatrix{T})
m, n = size(A)
if m != n error("expm!: Matrix A must be square") end
if m != n error("matrix must be square") end
if m < 2 return exp(A) end
ilo, ihi, scale = LAPACK.gebal!('B', A) # modifies A
nA = norm(A, 1)
Expand Down Expand Up @@ -554,9 +554,9 @@ function cond(A::StridedMatrix, p)
return maxv == 0.0 ? Inf : maxv / minimum(v)
elseif p == 1 || p == Inf
m, n = size(A)
if m != n; error("Use 2-norm for non-square matrices"); end
if m != n; error("wse 2-norm for non-square matrices"); end
return cond(lufact(A), p)
end
error("Norm type must be 1, 2 or Inf")
error("norm type must be 1, 2, or Inf")
end
cond(A::StridedMatrix) = cond(A, 2)
Loading

0 comments on commit 704b852

Please sign in to comment.