File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
NDTensors/src/lib/GradedAxes Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 6868# == is just a range comparison that ignores labels. Need dedicated function to check equality.
6969struct NoLabel end
7070blocklabels (r:: AbstractUnitRange ) = Fill (NoLabel (), blocklength (r))
71+ blocklabels (la:: LabelledUnitRange ) = label (la)
7172
7273function LabelledNumbers. labelled_isequal (a1:: AbstractUnitRange , a2:: AbstractUnitRange )
7374 return blockisequal (a1, a2) && (blocklabels (a1) == blocklabels (a2))
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ nondual(a::LabelledUnitRangeDual) = a.nondual_unitrange
1212dual (a:: LabelledUnitRangeDual ) = nondual (a)
1313flip (a:: LabelledUnitRangeDual ) = dual (flip (nondual (a)))
1414isdual (:: LabelledUnitRangeDual ) = true
15+ blocklabels (la:: LabelledUnitRangeDual ) = label (la)
1516
1617LabelledNumbers. label (a:: LabelledUnitRangeDual ) = dual (label (nondual (a)))
1718LabelledNumbers. unlabel (a:: LabelledUnitRangeDual ) = unlabel (nondual (a))
Original file line number Diff line number Diff line change 7373 @test label (lad) == U1 (- 1 )
7474 @test unlabel (lad) == 1 : 2
7575 @test lad == 1 : 2
76+ @test ! labelled_isequal (la, lad)
77+ @test ! space_isequal (la, lad)
78+ @test isdual (lad)
79+ @test nondual (lad) === la
80+ @test dual (lad) === la
81+
82+ # check default behavior for objects without dual
83+ la = labelled (1 : 2 , ' x' )
84+ lad = dual (la)
85+ @test lad isa LabelledUnitRangeDual
86+ @test label (lad) == ' x'
87+ @test unlabel (lad) == 1 : 2
88+ @test lad == 1 : 2
89+ @test labelled_isequal (la, lad)
90+ @test ! space_isequal (la, lad)
7691 @test isdual (lad)
7792 @test nondual (lad) === la
7893 @test dual (lad) === la
You can’t perform that action at this time.
0 commit comments