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

LinearAlgebra: LazyString in error messages for Diagonal/Bidiagonal #55070

Merged
merged 1 commit into from
Jul 10, 2024
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
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