Skip to content

Commit b4380b0

Browse files
committed
use NoLabel as default blocklabel
1 parent 65dc71e commit b4380b0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

NDTensors/src/lib/GradedAxes/src/fusion.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct OneToOne{T} <: AbstractUnitRange{T} end
55
OneToOne() = OneToOne{Bool}()
66
Base.first(a::OneToOne) = one(eltype(a))
77
Base.last(a::OneToOne) = one(eltype(a))
8+
BlockArrays.blockaxes(::OneToOne{Bool}) = (Block.(OneToOne()),)
89

910
# https://github.com/ITensor/ITensors.jl/blob/v0.3.57/NDTensors/src/lib/GradedAxes/src/tensor_product.jl
1011
# https://en.wikipedia.org/wiki/Tensor_product

NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using BlockArrays:
1919
findblockindex,
2020
mortar
2121
using Compat: allequal
22+
using FillArrays: Fill
2223
using ..LabelledNumbers:
2324
LabelledNumbers, LabelledInteger, LabelledUnitRange, label, labelled, unlabel
2425

@@ -38,7 +39,9 @@ function Base.OrdinalRange{T,T}(a::GradedOneTo{<:LabelledInteger{T}}) where {T}
3839
end
3940

4041
# == is just a range comparison that ignores labels. Need dedicated function to check equality.
41-
blocklabels(::AbstractUnitRange) = nothing
42+
struct NoLabel end
43+
blocklabels(r::AbstractUnitRange) = Fill(NoLabel(), blocklength(r))
44+
4245
function labelled_isequal(a1::AbstractUnitRange, a2::AbstractUnitRange)
4346
return blockisequal(a1, a2) && (blocklabels(a1) == blocklabels(a2))
4447
end

0 commit comments

Comments
 (0)