Skip to content

Commit

Permalink
blocklabels to return Vector
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Nov 7, 2024
1 parent b66c22f commit e44876a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end
# == is just a range comparison that ignores labels. Need dedicated function to check equality.
struct NoLabel end
blocklabels(r::AbstractUnitRange) = Fill(NoLabel(), blocklength(r))
blocklabels(la::LabelledUnitRange) = label(la)
blocklabels(la::LabelledUnitRange) = [label(la)]

function LabelledNumbers.labelled_isequal(a1::AbstractUnitRange, a2::AbstractUnitRange)
return blockisequal(a1, a2) && (blocklabels(a1) == blocklabels(a2))
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ nondual(a::LabelledUnitRangeDual) = a.nondual_unitrange
dual(a::LabelledUnitRangeDual) = nondual(a)
flip(a::LabelledUnitRangeDual) = dual(flip(nondual(a)))
isdual(::LabelledUnitRangeDual) = true
blocklabels(la::LabelledUnitRangeDual) = label(la)
blocklabels(la::LabelledUnitRangeDual) = [label(la)]

LabelledNumbers.label(a::LabelledUnitRangeDual) = dual(label(nondual(a)))
LabelledNumbers.unlabel(a::LabelledUnitRangeDual) = unlabel(nondual(a))
Expand Down
6 changes: 3 additions & 3 deletions NDTensors/src/lib/GradedAxes/test/test_dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ end
la = labelled(1:2, U1(1))
@test la isa LabelledUnitRange
@test label(la) == U1(1)
@test blocklabels(la) == U1(1)
@test blocklabels(la) == [U1(1)]
@test unlabel(la) == 1:2
@test la == 1:2
@test !isdual(la)
Expand All @@ -74,7 +74,7 @@ end
lad = dual(la)
@test lad isa LabelledUnitRangeDual
@test label(lad) == U1(-1)
@test blocklabels(lad) == U1(-1)
@test blocklabels(lad) == [U1(-1)]
@test unlabel(lad) == 1:2
@test lad == 1:2
@test labelled_isequal(lad, lad)
Expand All @@ -90,7 +90,7 @@ end
lad = dual(la)
@test lad isa LabelledUnitRangeDual
@test label(lad) == 'x'
@test blocklabels(la) == 'x'
@test blocklabels(lad) == ['x']
@test unlabel(lad) == 1:2
@test lad == 1:2
@test labelled_isequal(lad, lad)
Expand Down

0 comments on commit e44876a

Please sign in to comment.