Skip to content

Commit

Permalink
LinearAlgebra: LazyString in error messages for Diagonal/Bidiagonal (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Jul 10, 2024
1 parent 2759961 commit ec013f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ end
elseif A.uplo == 'L' && (i == j + 1)
@inbounds A.ev[j] = x
elseif !iszero(x)
throw(ArgumentError(string("cannot set entry ($i, $j) off the ",
"$(istriu(A) ? "upper" : "lower") bidiagonal band to a nonzero value ($x)")))
throw(ArgumentError(LazyString(lazy"cannot set entry ($i, $j) off the ",
istriu(A) ? "upper" : "lower", " bidiagonal band to a nonzero value ", x)))
end
return x
end
Expand Down Expand Up @@ -320,7 +320,7 @@ function _copyto_banded!(A::Bidiagonal, B::Bidiagonal)
else
zeroband = istriu(A) ? "lower" : "upper"
uplo = A.uplo
throw(ArgumentError(string("cannot set the ",
throw(ArgumentError(LazyString("cannot set the ",
zeroband, " bidiagonal band to a nonzero value for uplo=:", uplo)))
end
return A
Expand Down Expand Up @@ -373,8 +373,8 @@ ishermitian(M::Bidiagonal) = isdiag(M) && all(ishermitian, M.dv)
function tril!(M::Bidiagonal{T}, k::Integer=0) where T
n = length(M.dv)
if !(-n - 1 <= k <= n - 1)
throw(ArgumentError(string("the requested diagonal, $k, must be at least ",
"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
throw(ArgumentError(LazyString(lazy"the requested diagonal, $k, must be at least ",
lazy"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
elseif M.uplo == 'U' && k < 0
fill!(M.dv, zero(T))
fill!(M.ev, zero(T))
Expand All @@ -392,8 +392,8 @@ end
function triu!(M::Bidiagonal{T}, k::Integer=0) where T
n = length(M.dv)
if !(-n + 1 <= k <= n + 1)
throw(ArgumentError(string("the requested diagonal, $k, must be at least",
"$(-n + 1) and at most $(n + 1) in an $n-by-$n matrix")))
throw(ArgumentError(LazyString(lazy"the requested diagonal, $k, must be at least",
lazy"$(-n + 1) and at most $(n + 1) in an $n-by-$n matrix")))
elseif M.uplo == 'L' && k > 0
fill!(M.dv, zero(T))
fill!(M.ev, zero(T))
Expand All @@ -418,8 +418,8 @@ function diag(M::Bidiagonal{T}, n::Integer=0) where T
elseif -size(M,1) <= n <= size(M,1)
return fill!(similar(M.dv, size(M,1)-abs(n)), zero(T))
else
throw(ArgumentError(string("requested diagonal, $n, must be at least $(-size(M, 1)) ",
"and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix")))
throw(ArgumentError(LazyString(lazy"requested diagonal, $n, must be at least $(-size(M, 1)) ",
lazy"and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix")))
end
end

Expand Down
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/src/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ end
function tril!(D::Diagonal{T}, k::Integer=0) where T
n = size(D,1)
if !(-n - 1 <= k <= n - 1)
throw(ArgumentError(string("the requested diagonal, $k, must be at least ",
"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
throw(ArgumentError(LazyString(lazy"the requested diagonal, $k, must be at least ",
lazy"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
elseif k < 0
fill!(D.diag, zero(T))
end
Expand Down

0 comments on commit ec013f1

Please sign in to comment.