From 22e9ac97196746fa7c89b820052f7a3b7406d325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Gauth=C3=A9?= Date: Thu, 3 Oct 2024 16:21:53 -0400 Subject: [PATCH] reorder file --- .../src/lib/Sectors/src/category_product.jl | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/NDTensors/src/lib/Sectors/src/category_product.jl b/NDTensors/src/lib/Sectors/src/category_product.jl index 37a1c3b30d..7c98a4e545 100644 --- a/NDTensors/src/lib/Sectors/src/category_product.jl +++ b/NDTensors/src/lib/Sectors/src/category_product.jl @@ -61,10 +61,33 @@ end # - ordered-like with a Tuple # - dictionary-like with a NamedTuple +categories_isequal(o1::Tuple, o2::Tuple) = (o1 == o2) +function categories_isequal(nt::NamedTuple, ::Tuple{}) + return categories_isequal(nt, (;)) +end +function categories_isequal(::Tuple{}, nt::NamedTuple) + return categories_isequal((;), nt) +end +function categories_isequal(nt1::NamedTuple, nt2::NamedTuple) + return ==(sym_categories_insert_unspecified(nt1, nt2)...) +end + # get clean results when mixing implementations categories_isequal(::Tuple, ::NamedTuple) = false categories_isequal(::NamedTuple, ::Tuple) = false +categories_isless(::Tuple, ::Tuple) = throw(ArgumentError("Not implemented")) +categories_isless(t1::T, t2::T) where {T<:Tuple} = t1 < t2 +function categories_isless(nt::NamedTuple, ::Tuple{}) + return categories_isless(nt, (;)) +end +function categories_isless(::Tuple{}, nt::NamedTuple) + return categories_isless((;), nt) +end +function categories_isless(nt1::NamedTuple, nt2::NamedTuple) + return isless(sym_categories_insert_unspecified(nt1, nt2)...) +end + categories_isless(::NamedTuple, ::Tuple) = throw(ArgumentError("Not implemented")) categories_isless(::Tuple, ::NamedTuple) = throw(ArgumentError("Not implemented")) @@ -184,11 +207,6 @@ function SymmetryStyle(T::Type{<:Tuple}) return mapreduce(SymmetryStyle, combine_styles, fieldtypes(T); init=AbelianStyle()) end -categories_isequal(o1::Tuple, o2::Tuple) = (o1 == o2) - -categories_isless(::Tuple, ::Tuple) = throw(ArgumentError("Not implemented")) -categories_isless(t1::T, t2::T) where {T<:Tuple} = t1 < t2 - categories_product(l1::Tuple, l2::Tuple) = (l1..., l2...) categories_trivial(type::Type{<:Tuple}) = trivial.(fieldtypes(type)) @@ -230,26 +248,6 @@ function SymmetryStyle(NT::Type{<:NamedTuple}) return mapreduce(SymmetryStyle, combine_styles, fieldtypes(NT); init=AbelianStyle()) end -function categories_isequal(nt::NamedTuple, ::Tuple{}) - return categories_isequal(nt, (;)) -end -function categories_isequal(::Tuple{}, nt::NamedTuple) - return categories_isequal((;), nt) -end -function categories_isequal(nt1::NamedTuple, nt2::NamedTuple) - return ==(sym_categories_insert_unspecified(nt1, nt2)...) -end - -function categories_isless(nt::NamedTuple, ::Tuple{}) - return categories_isless(nt, (;)) -end -function categories_isless(::Tuple{}, nt::NamedTuple) - return categories_isless((;), nt) -end -function categories_isless(nt1::NamedTuple, nt2::NamedTuple) - return isless(sym_categories_insert_unspecified(nt1, nt2)...) -end - function sym_categories_insert_unspecified(nt1::NamedTuple, nt2::NamedTuple) return categories_insert_unspecified(nt1, nt2), categories_insert_unspecified(nt2, nt1) end