Skip to content

Commit

Permalink
LinearAlgebra: LazyString in error messages for Diagonal/Bidiagonal (#…
Browse files Browse the repository at this point in the history
…55070)

(cherry picked from commit ec013f1)
  • Loading branch information
jishnub authored and KristofferC committed Jul 23, 2024
1 parent 54bd4b9 commit 3387373
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions stdlib/LinearAlgebra/src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,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 @@ -343,8 +343,8 @@ isdiag(M::Bidiagonal) = iszero(M.ev)
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 @@ -362,8 +362,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 @@ -388,8 +388,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 @@ -237,8 +237,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 3387373

Please sign in to comment.