From 135b5eaaa5935995f8142ff1270a8c2263bfefe8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Nov 2023 00:42:57 +0100 Subject: [PATCH] Format code (#119) Co-authored-by: mofeing --- ext/TenetChainRulesCoreExt.jl | 2 +- ext/TenetChainRulesTestUtilsExt.jl | 2 +- ext/TenetFiniteDifferencesExt.jl | 2 +- src/Numerics.jl | 8 +++++++- src/Quantum/Quantum.jl | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ext/TenetChainRulesCoreExt.jl b/ext/TenetChainRulesCoreExt.jl index db52a1ed9..fb60a8b35 100644 --- a/ext/TenetChainRulesCoreExt.jl +++ b/ext/TenetChainRulesCoreExt.jl @@ -68,4 +68,4 @@ function ChainRulesCore.rrule(T::Type{<:absclass(TensorNetwork)}, tensors) T(tensors), TensorNetwork_pullback end -end \ No newline at end of file +end diff --git a/ext/TenetChainRulesTestUtilsExt.jl b/ext/TenetChainRulesTestUtilsExt.jl index aea16d949..135e7a643 100644 --- a/ext/TenetChainRulesTestUtilsExt.jl +++ b/ext/TenetChainRulesTestUtilsExt.jl @@ -10,4 +10,4 @@ function ChainRulesTestUtils.rand_tangent(rng::AbstractRNG, x::T) where {T<:absc return Tangent{T}(tensors = [ProjectTo(tensor)(rand_tangent.(Ref(rng), tensor)) for tensor in tensors(x)]) end -end \ No newline at end of file +end diff --git a/ext/TenetFiniteDifferencesExt.jl b/ext/TenetFiniteDifferencesExt.jl index cf39c270f..1389978db 100644 --- a/ext/TenetFiniteDifferencesExt.jl +++ b/ext/TenetFiniteDifferencesExt.jl @@ -22,4 +22,4 @@ function FiniteDifferences.to_vec(x::T) where {T<:absclass(TensorNetwork)} return x_vec, TensorNetwork_from_vec end -end \ No newline at end of file +end diff --git a/src/Numerics.jl b/src/Numerics.jl index ac4e882bc..209ca8cfd 100644 --- a/src/Numerics.jl +++ b/src/Numerics.jl @@ -121,15 +121,21 @@ LinearAlgebra.qr(t::Tensor{<:Any,2}; kwargs...) = Base.@invoke qr(t::Tensor; lef """ LinearAlgebra.qr(t::Tensor, mode::Symbol = :reduced; left_inds = (), right_inds = (), virtualind::Symbol = Symbol(uuid4()), kwargs... + Perform QR factorization on a tensor. + # Arguments + - `t::Tensor`: tensor to be factorized + # Keyword Arguments + - `left_inds`: left indices to be used in the QR factorization. Defaults to all indices of `t` except `right_inds`. - `right_inds`: right indices to be used in the QR factorization. Defaults to all indices of `t` except `left_inds`. - `virtualind`: name of the virtual bond. Defaults to a random `Symbol`. """ -function LinearAlgebra.qr(t::Tensor; left_inds = (), right_inds = (), virtualind::Symbol = Symbol(uuid4()), kwargs...) isdisjoint(left_inds, right_inds) || +function LinearAlgebra.qr(t::Tensor; left_inds = (), right_inds = (), virtualind::Symbol = Symbol(uuid4()), kwargs...) + isdisjoint(left_inds, right_inds) || throw(ArgumentError("left ($left_inds) and right $(right_inds) indices must be disjoint")) left_inds, right_inds = diff --git a/src/Quantum/Quantum.jl b/src/Quantum/Quantum.jl index 65b4bbe42..180aa8541 100644 --- a/src/Quantum/Quantum.jl +++ b/src/Quantum/Quantum.jl @@ -255,4 +255,4 @@ Base.getproperty(obj::QTNSampler, name::Symbol) = name === :config ? getfield(ob Base.get(obj::QTNSampler, name, default) = get(obj.config, name, default) Base.rand(A::Type{<:Ansatz}; kwargs...) = rand(Random.default_rng(), A; kwargs...) -Base.rand(rng::AbstractRNG, A::Type{<:Ansatz}; kwargs...) = rand(rng, QTNSampler{A}(; kwargs...)) \ No newline at end of file +Base.rand(rng::AbstractRNG, A::Type{<:Ansatz}; kwargs...) = rand(rng, QTNSampler{A}(; kwargs...))