Skip to content

Commit ec013f1

Browse files
authored
LinearAlgebra: LazyString in error messages for Diagonal/Bidiagonal (#55070)
1 parent 2759961 commit ec013f1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

stdlib/LinearAlgebra/src/bidiag.jl

+9-9
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ end
191191
elseif A.uplo == 'L' && (i == j + 1)
192192
@inbounds A.ev[j] = x
193193
elseif !iszero(x)
194-
throw(ArgumentError(string("cannot set entry ($i, $j) off the ",
195-
"$(istriu(A) ? "upper" : "lower") bidiagonal band to a nonzero value ($x)")))
194+
throw(ArgumentError(LazyString(lazy"cannot set entry ($i, $j) off the ",
195+
istriu(A) ? "upper" : "lower", " bidiagonal band to a nonzero value ", x)))
196196
end
197197
return x
198198
end
@@ -320,7 +320,7 @@ function _copyto_banded!(A::Bidiagonal, B::Bidiagonal)
320320
else
321321
zeroband = istriu(A) ? "lower" : "upper"
322322
uplo = A.uplo
323-
throw(ArgumentError(string("cannot set the ",
323+
throw(ArgumentError(LazyString("cannot set the ",
324324
zeroband, " bidiagonal band to a nonzero value for uplo=:", uplo)))
325325
end
326326
return A
@@ -373,8 +373,8 @@ ishermitian(M::Bidiagonal) = isdiag(M) && all(ishermitian, M.dv)
373373
function tril!(M::Bidiagonal{T}, k::Integer=0) where T
374374
n = length(M.dv)
375375
if !(-n - 1 <= k <= n - 1)
376-
throw(ArgumentError(string("the requested diagonal, $k, must be at least ",
377-
"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
376+
throw(ArgumentError(LazyString(lazy"the requested diagonal, $k, must be at least ",
377+
lazy"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
378378
elseif M.uplo == 'U' && k < 0
379379
fill!(M.dv, zero(T))
380380
fill!(M.ev, zero(T))
@@ -392,8 +392,8 @@ end
392392
function triu!(M::Bidiagonal{T}, k::Integer=0) where T
393393
n = length(M.dv)
394394
if !(-n + 1 <= k <= n + 1)
395-
throw(ArgumentError(string("the requested diagonal, $k, must be at least",
396-
"$(-n + 1) and at most $(n + 1) in an $n-by-$n matrix")))
395+
throw(ArgumentError(LazyString(lazy"the requested diagonal, $k, must be at least",
396+
lazy"$(-n + 1) and at most $(n + 1) in an $n-by-$n matrix")))
397397
elseif M.uplo == 'L' && k > 0
398398
fill!(M.dv, zero(T))
399399
fill!(M.ev, zero(T))
@@ -418,8 +418,8 @@ function diag(M::Bidiagonal{T}, n::Integer=0) where T
418418
elseif -size(M,1) <= n <= size(M,1)
419419
return fill!(similar(M.dv, size(M,1)-abs(n)), zero(T))
420420
else
421-
throw(ArgumentError(string("requested diagonal, $n, must be at least $(-size(M, 1)) ",
422-
"and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix")))
421+
throw(ArgumentError(LazyString(lazy"requested diagonal, $n, must be at least $(-size(M, 1)) ",
422+
lazy"and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix")))
423423
end
424424
end
425425

stdlib/LinearAlgebra/src/diagonal.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ end
254254
function tril!(D::Diagonal{T}, k::Integer=0) where T
255255
n = size(D,1)
256256
if !(-n - 1 <= k <= n - 1)
257-
throw(ArgumentError(string("the requested diagonal, $k, must be at least ",
258-
"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
257+
throw(ArgumentError(LazyString(lazy"the requested diagonal, $k, must be at least ",
258+
lazy"$(-n - 1) and at most $(n - 1) in an $n-by-$n matrix")))
259259
elseif k < 0
260260
fill!(D.diag, zero(T))
261261
end

0 commit comments

Comments
 (0)