From e44876aebbf912bf53e47b1a8ec76a013ce8785b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Gauth=C3=A9?= Date: Thu, 7 Nov 2024 12:41:54 -0500 Subject: [PATCH] blocklabels to return Vector --- NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl | 2 +- NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl | 2 +- NDTensors/src/lib/GradedAxes/test/test_dual.jl | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl b/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl index 9197a99fe8..76eaf42692 100644 --- a/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl +++ b/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl @@ -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)) diff --git a/NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl b/NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl index 0dd13ddb5a..0c0679a01f 100644 --- a/NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl +++ b/NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl @@ -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)) diff --git a/NDTensors/src/lib/GradedAxes/test/test_dual.jl b/NDTensors/src/lib/GradedAxes/test/test_dual.jl index 8fdc811905..f9506a8fa0 100644 --- a/NDTensors/src/lib/GradedAxes/test/test_dual.jl +++ b/NDTensors/src/lib/GradedAxes/test/test_dual.jl @@ -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) @@ -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) @@ -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)