Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
Closed
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GradedUnitRanges"
uuid = "e2de450a-8a67-46c7-b59c-01d5a3d041c5"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.1.6"
version = "0.2.0"

[deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Expand All @@ -22,5 +22,5 @@ Compat = "4.16.0"
FillArrays = "1.13.0"
LabelledNumbers = "0.1.0"
SplitApplyCombine = "1.2.3"
SymmetrySectors = "0.1.4"
SymmetrySectors = "0.2.0"
julia = "1.10"
2 changes: 0 additions & 2 deletions src/GradedUnitRanges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ export gradedrange
include("blockedunitrange.jl")
include("gradedunitrange.jl")
include("dual.jl")
include("labelledunitrangedual.jl")
include("gradedunitrangedual.jl")
include("onetoone.jl")
include("fusion.jl")

Expand Down
17 changes: 10 additions & 7 deletions src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ By default, it just returns `x`, i.e. it assumes the object
is self-dual.
"""
dual(x) = x
isdual(x) = isdual(typeof(x))
isdual(::Type) = false

nondual(r::AbstractUnitRange) = r
isdual(::AbstractUnitRange) = false

dual_type(x) = dual_type(typeof(x))
dual_type(T::Type) = T
nondual_type(x) = nondual_type(typeof(x))
nondual_type(T::Type) = T
nondual_type(T::Type) = isdual(T) ? dual_type(T) : T
nondual(r::AbstractUnitRange) = map_blocklabels(nondual, r)
isdual(R::Type{<:AbstractUnitRange}) = isdual(eltype(R))
isdual(L::Type{<:LabelledInteger}) = isdual(label_type(L))

dual(i::LabelledInteger) = labelled(unlabel(i), dual(label(i)))
flip(a::AbstractUnitRange) = dual(map_blocklabels(dual, a))
dual(a::AbstractUnitRange) = map_blocklabels(dual, a)
flip(a::AbstractUnitRange) = map_blocklabels(flip, a)

flip_dual(x) = isdual(x) ? flip(x) : x

"""
dag(r::AbstractUnitRange)
Expand Down
3 changes: 0 additions & 3 deletions src/fusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function tensor_product(
end

flip_dual(r::AbstractUnitRange) = r
flip_dual(r::GradedUnitRangeDual) = flip(r)
function tensor_product(a1::AbstractUnitRange, a2::AbstractUnitRange)
return tensor_product(flip_dual(a1), flip_dual(a2))
end
Expand Down Expand Up @@ -93,7 +92,6 @@ function blockmergesort(g::AbstractGradedUnitRange)
return gradedrange(new_blocklengths)
end

blockmergesort(g::GradedUnitRangeDual) = flip(blockmergesort(flip(g)))
blockmergesort(g::AbstractUnitRange) = g

# fusion_product produces a sorted, non-dual GradedUnitRange
Expand All @@ -102,7 +100,6 @@ function fusion_product(g1, g2)
end

fusion_product(g::AbstractUnitRange) = blockmergesort(g)
fusion_product(g::GradedUnitRangeDual) = fusion_product(flip(g))

# recursive fusion_product. Simpler than reduce + fix type stability issues with reduce
function fusion_product(g1, g2, g3...)
Expand Down
10 changes: 4 additions & 6 deletions src/gradedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using BlockArrays:
BlockedUnitRange,
block,
blockedrange,
blockfirsts,
blockisequal,
blocklasts,
blocklength,
Expand Down Expand Up @@ -72,10 +73,6 @@ function LabelledNumbers.labelled_isequal(a1::AbstractUnitRange, a2::AbstractUni
return blockisequal(a1, a2) && (blocklabels(a1) == blocklabels(a2))
end

function space_isequal(a1::AbstractUnitRange, a2::AbstractUnitRange)
return (isdual(a1) == isdual(a2)) && labelled_isequal(a1, a2)
end

# needed in BlockSparseArrays
function Base.AbstractUnitRange{T}(
a::AbstractGradedUnitRange{<:LabelledInteger{T}}
Expand All @@ -95,8 +92,9 @@ LabelledNumbers.label_type(T::Type{<:AbstractGradedUnitRange}) = label_type(elty
to_sector(x) = x

sector_type(x) = sector_type(typeof(x))
sector_type(T::Type) = error("Not implemented")
sector_type(T::Type{<:AbstractUnitRange}) = label_type(T)
sector_type(::Type) = error("Not implemented")
sector_type(T::Type{<:AbstractUnitRange}) = sector_type(eltype(T))
sector_type(T::Type{<:LabelledInteger}) = nondual_type(label_type(T))

# To help with generic code.
function BlockArrays.blockedrange(lblocklengths::AbstractVector{<:LabelledInteger})
Expand Down
155 changes: 0 additions & 155 deletions src/gradedunitrangedual.jl

This file was deleted.

66 changes: 0 additions & 66 deletions src/labelledunitrangedual.jl

This file was deleted.

1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LabelledNumbers = "f856a3a6-4152-4ec4-b2a7-02c1a55d7993"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[compat]
Aqua = "0.8.9"
Expand Down
4 changes: 2 additions & 2 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using GradedUnitRanges:
blocklabels,
gradedrange,
sector_type,
space_isequal
labelled_isequal
using LabelledNumbers:
LabelledUnitRange, islabelled, label, labelled, labelled_isequal, unlabel
using Test: @test, @test_broken, @testset
Expand Down Expand Up @@ -110,7 +110,7 @@ end
b = combine_blockaxes(a, a)
@test b isa GradedOneTo
@test b == 1:5
@test space_isequal(b, a)
@test labelled_isequal(b, a)
end

# Slicing operations
Expand Down
Loading