Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoundsError does not take a string #14824

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions base/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ function axpy!{T<:BlasFloat,Ta<:Number,Ti<:Integer}(alpha::Ta, x::Array{T}, rx::
throw(DimensionMismatch("ranges of differing lengths"))
end
if minimum(rx) < 1 || maximum(rx) > length(x)
throw(BoundsError("range out of bounds for x, of length $(length(x))"))
throw(ArgumentError("range out of bounds for x, of length $(length(x))"))
end
if minimum(ry) < 1 || maximum(ry) > length(y)
throw(BoundsError("range out of bounds for y, of length $(length(y))"))
throw(ArgumentError("range out of bounds for y, of length $(length(y))"))
end
axpy!(length(rx), convert(T, alpha), pointer(x)+(first(rx)-1)*sizeof(T), step(rx), pointer(y)+(first(ry)-1)*sizeof(T), step(ry))
y
Expand Down Expand Up @@ -1307,10 +1307,10 @@ end # module
function copy!{T<:BlasFloat,Ti<:Integer}(dest::Array{T}, rdest::Union{UnitRange{Ti},Range{Ti}},
src::Array{T}, rsrc::Union{UnitRange{Ti},Range{Ti}})
if minimum(rdest) < 1 || maximum(rdest) > length(dest)
throw(BoundsError("range out of bounds for dest, of length $(length(dest))"))
throw(ArgumentError("range out of bounds for dest, of length $(length(dest))"))
end
if minimum(rsrc) < 1 || maximum(rsrc) > length(src)
throw(BoundsError("range out of bounds for src, of length $(length(src))"))
throw(ArgumentError("range out of bounds for src, of length $(length(src))"))
end
if length(rdest) != length(rsrc)
throw(DimensionMismatch("ranges must be of the same length"))
Expand Down
8 changes: 4 additions & 4 deletions base/linalg/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function diag{T}(M::SymTridiagonal{T}, n::Integer=0)
elseif absn<size(M,1)
return zeros(T,size(M,1)-absn)
else
throw(BoundsError("$n-th diagonal of a $(size(M)) matrix doesn't exist!"))
throw(ArgumentError("$n-th diagonal of a $(size(M)) matrix doesn't exist!"))
end
end

Expand Down Expand Up @@ -257,7 +257,7 @@ det(A::SymTridiagonal) = det_usmani(A.ev, A.dv, A.ev)

function getindex{T}(A::SymTridiagonal{T}, i::Integer, j::Integer)
if !(1 <= i <= size(A,2) && 1 <= j <= size(A,2))
throw(BoundsError("(i,j) = ($i,$j) not within matrix of size $(size(A))"))
throw(BoundsError(A, (i,j)))
end
if i == j
return A.dv[i]
Expand Down Expand Up @@ -362,13 +362,13 @@ function diag{T}(M::Tridiagonal{T}, n::Integer=0)
elseif abs(n) < size(M,1)
return zeros(T,size(M,1)-abs(n))
else
throw(BoundsError("$n-th diagonal of a $(size(M)) matrix doesn't exist!"))
throw(ArgumentError("$n-th diagonal of a $(size(M)) matrix doesn't exist!"))
end
end

function getindex{T}(A::Tridiagonal{T}, i::Integer, j::Integer)
if !(1 <= i <= size(A,2) && 1 <= j <= size(A,2))
throw(BoundsError("(i,j) = ($i,$j) not within matrix of size $(size(A))"))
throw(BoundsError(A, (i,j)))
end
if i == j
return A.d[i]
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function umferror(status::Integer)
elseif status==UMFPACK_ERROR_argument_missing
throw(ArgumentError("a required argument to UMFPack is missing"))
elseif status==UMFPACK_ERROR_n_nonpositive
throw(BoundsError("the number of rows or columns of the matrix must be greater than zero"))
throw(ArgumentError("the number of rows or columns of the matrix must be greater than zero"))
elseif status==UMFPACK_ERROR_invalid_matrix
throw(ArgumentError("invalid matrix"))
elseif status==UMFPACK_ERROR_different_pattern
Expand Down
12 changes: 6 additions & 6 deletions test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ for elty in [Float32, Float64, Complex64, Complex128]
@test_approx_eq BLAS.axpy!(α,copy(x1),copy(x2)) x2 + α*x1
@test_throws DimensionMismatch BLAS.axpy!(α, copy(x1), rand(elty, n + 1))
@test_throws DimensionMismatch BLAS.axpy!(α, copy(x1), 1:div(n,2), copy(x2), 1:n)
@test_throws BoundsError BLAS.axpy!(α, copy(x1), 0:div(n,2), copy(x2), 1:(div(n, 2) + 1))
@test_throws BoundsError BLAS.axpy!(α, copy(x1), 1:div(n,2), copy(x2), 0:(div(n, 2) - 1))
@test_throws ArgumentError BLAS.axpy!(α, copy(x1), 0:div(n,2), copy(x2), 1:(div(n, 2) + 1))
@test_throws ArgumentError BLAS.axpy!(α, copy(x1), 1:div(n,2), copy(x2), 0:(div(n, 2) - 1))
@test_approx_eq BLAS.axpy!(α,copy(x1),1:n,copy(x2),1:n) x2 + α*x1
else
z1 = convert(Vector{elty}, complex(randn(n), randn(n)))
Expand All @@ -94,8 +94,8 @@ for elty in [Float32, Float64, Complex64, Complex128]
@test_approx_eq BLAS.axpy!(α, copy(z1), copy(z2)) z2 + α * z1
@test_throws DimensionMismatch BLAS.axpy!(α, copy(z1), rand(elty, n + 1))
@test_throws DimensionMismatch BLAS.axpy!(α, copy(z1), 1:div(n, 2), copy(z2), 1:(div(n, 2) + 1))
@test_throws BoundsError BLAS.axpy!(α, copy(z1), 0:div(n,2), copy(z2), 1:(div(n, 2) + 1))
@test_throws BoundsError BLAS.axpy!(α, copy(z1), 1:div(n,2), copy(z2), 0:(div(n, 2) - 1))
@test_throws ArgumentError BLAS.axpy!(α, copy(z1), 0:div(n,2), copy(z2), 1:(div(n, 2) + 1))
@test_throws ArgumentError BLAS.axpy!(α, copy(z1), 1:div(n,2), copy(z2), 0:(div(n, 2) - 1))
@test_approx_eq BLAS.axpy!(α,copy(z1),1:n,copy(z2),1:n) z2 + α*z1
end

Expand Down Expand Up @@ -150,8 +150,8 @@ for elty in [Float32, Float64, Complex64, Complex128]
BLAS.copy!(x2, 1:n, x1, 1:n)
@test x2 == x1
@test_throws DimensionMismatch BLAS.copy!(x2, 1:n, x1, 1:(n - 1))
@test_throws BoundsError BLAS.copy!(x1, 0:div(n, 2), x2, 1:(div(n, 2) + 1))
@test_throws BoundsError BLAS.copy!(x1, 1:(div(n, 2) + 1), x2, 0:div(n, 2))
@test_throws ArgumentError BLAS.copy!(x1, 0:div(n, 2), x2, 1:(div(n, 2) + 1))
@test_throws ArgumentError BLAS.copy!(x1, 1:(div(n, 2) + 1), x2, 0:div(n, 2))

# symv and hemv

Expand Down
4 changes: 2 additions & 2 deletions test/linalg/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ let n = 12 #Size of matrix problem to test
@test diag(A,-1) == b
@test diag(A,0) == a
@test diag(A,n-1) == zeros(elty,1)
@test_throws BoundsError diag(A,n+1)
@test_throws ArgumentError diag(A,n+1)

debug && println("Idempotent tests")
for func in (conj, transpose, ctranspose)
Expand Down Expand Up @@ -335,7 +335,7 @@ let n = 12 #Size of matrix problem to test
@test diag(A,0) == b
@test diag(A,1) == c
@test diag(A,n-1) == zeros(elty,1)
@test_throws BoundsError diag(A,n+1)
@test_throws ArgumentError diag(A,n+1)

debug && println("Simple unary functions")
for func in (det, inv)
Expand Down
2 changes: 2 additions & 0 deletions test/sparsedir/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ x = speye(2) + im * speye(2)

@test det(sparse([1,3,3,1], [1,1,3,3], [1,1,1,1])) == 0

# UMFPACK_ERROR_n_nonpositive
@test_throws ArgumentError lufact(sparse(Int[], Int[], Float64[], 5, 0))