From 33873732fe2b55813f01b95a95625213f16c8ab3 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 10 Jul 2024 09:45:20 +0530 Subject: [PATCH] LinearAlgebra: LazyString in error messages for Diagonal/Bidiagonal (#55070) (cherry picked from commit ec013f10cc0c6528a2390e7233e4a5440d677f99) --- stdlib/LinearAlgebra/src/bidiag.jl | 16 ++++++++-------- stdlib/LinearAlgebra/src/diagonal.jl | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stdlib/LinearAlgebra/src/bidiag.jl b/stdlib/LinearAlgebra/src/bidiag.jl index d356379f34dff..91e41855bcbc6 100644 --- a/stdlib/LinearAlgebra/src/bidiag.jl +++ b/stdlib/LinearAlgebra/src/bidiag.jl @@ -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 @@ -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)) @@ -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)) @@ -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 diff --git a/stdlib/LinearAlgebra/src/diagonal.jl b/stdlib/LinearAlgebra/src/diagonal.jl index f07e0fba17f53..6ee4f1279b4fd 100644 --- a/stdlib/LinearAlgebra/src/diagonal.jl +++ b/stdlib/LinearAlgebra/src/diagonal.jl @@ -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