Skip to content

Commit

Permalink
Merge pull request #69 from JuliaLang/ksh/errortests
Browse files Browse the repository at this point in the history
Added error-throwing tests and fixed bugs
  • Loading branch information
jiahao committed Aug 22, 2016
2 parents 29d2056 + 4c6097e commit ef5e5fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/rlinalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function randnn(el, m::Int, normalize::Bool=true)
elseif el <: Complex
Ω = randn(m) + im*randn(m)
else
throw(ValueError("Unsupported element type: $el"))
throw(ArgumentError("Unsupported element type: $el"))
end
normalize ? Ω/norm(Ω) : Ω
end
Expand All @@ -35,7 +35,7 @@ function randnn(el, m::Int, n::Int, normalize::Bool=true)
elseif el <: Complex
Ω = randn(m, n) + im*randn(m, n)
else
throw(ValueError("Unsupported element type: $el"))
throw(ArgumentError("Unsupported element type: $el"))
end
normalize || return Ω
for i=1:n
Expand Down
2 changes: 1 addition & 1 deletion src/svdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ end
function Base.getindex{T}(B::BrokenArrowBidiagonal{T}, i::Int, j::Int)
n = size(B, 1)
k = length(B.av)
if !(1 i n || 1 j n)
if !(1 i n && 1 j n)
throw(BoundsError())
end

Expand Down
4 changes: 4 additions & 0 deletions test/rlinalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ facts("Randomized linear algebra") do

l, u = rcond(A, k, p)
@fact l <= cond(A) <= u --> true

@fact_throws ArgumentError IterativeSolvers.randnn(Char, m)
@fact_throws ArgumentError IterativeSolvers.randnn(Char, m, n)

end
7 changes: 5 additions & 2 deletions test/svdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ for method in (:ritz, :harmonic) context("Thick restart with method=$method") do
q = convert(Vector{elty}, ones(n)/√n)
σ, L = svdl(A, ns, v0=q, tol=tol, reltol=tol, maxiter=n, method=method, vecs=:none)
@fact norm- [n:-1.0:n-4;]) --> less_than(5^2*1e-5)
@fact_throws ArgumentError svdl(A, ns, v0=q, tol=tol, reltol=tol, maxiter=n, method=:fakemethod, vecs=:none)

#Check the singular vectors also
Σ, L = svdl(A, ns, v0=q, tol=tol, reltol=tol, maxiter=n, method=method, vecs=:both)
Expand Down Expand Up @@ -66,6 +67,8 @@ facts("BrokenArrowBidiagonal") do
@fact B[3,3] --> 3
@fact B[2,3] --> 2
@fact B[3,2] --> 0
@fact B[1,3] --> 1
@fact B[1,3] --> 1
@fact size(B) --> (3,3)
@fact_throws ArgumentError size(B,3)
@fact_throws BoundsError B[1,5]
end

0 comments on commit ef5e5fb

Please sign in to comment.