@@ -17,26 +17,28 @@ Base.step(a::GradedUnitRangeDual) = label_dual(step(nondual(a)))
1717
1818Base. view (a:: GradedUnitRangeDual , index:: Block{1} ) = a[index]
1919
20- function Base. getindex (a:: GradedUnitRangeDual , indices:: AbstractUnitRange{<:Integer} )
20+ function gradedunitrange_getindices (
21+ a:: GradedUnitRangeDual , indices:: AbstractUnitRange{<:Integer}
22+ )
2123 return dual (getindex (nondual (a), indices))
2224end
2325
2426using BlockArrays: Block, BlockIndexRange, BlockRange
2527
26- function Base . getindex (a:: GradedUnitRangeDual , indices:: Integer )
28+ function gradedunitrange_getindices (a:: GradedUnitRangeDual , indices:: Integer )
2729 return label_dual (getindex (nondual (a), indices))
2830end
2931
30- function Base . getindex (a:: GradedUnitRangeDual , indices:: Block{1} )
32+ function gradedunitrange_getindices (a:: GradedUnitRangeDual , indices:: Block{1} )
3133 return label_dual (getindex (nondual (a), indices))
3234end
3335
34- function Base . getindex (a:: GradedUnitRangeDual , indices:: BlockRange )
36+ function gradedunitrange_getindices (a:: GradedUnitRangeDual , indices:: BlockRange )
3537 return label_dual (getindex (nondual (a), indices))
3638end
3739
3840# fix ambiguity
39- function Base . getindex (
41+ function gradedunitrange_getindices (
4042 a:: GradedUnitRangeDual , indices:: BlockRange{1,<:Tuple{AbstractUnitRange{Int}}}
4143)
4244 return dual (getindex (nondual (a), indices))
@@ -52,15 +54,13 @@ function unitrangedual_getindices_blocks(a::GradedUnitRangeDual, indices)
5254end
5355
5456# TODO : Move this to a `BlockArraysExtensions` library.
55- function blockedunitrange_getindices (a:: GradedUnitRangeDual , indices:: Block{1} )
56- return a[indices]
57- end
58-
59- function Base. getindex (a:: GradedUnitRangeDual , indices:: Vector{<:Block{1}} )
57+ function gradedunitrange_getindices (a:: GradedUnitRangeDual , indices:: Vector{<:Block{1}} )
6058 return unitrangedual_getindices_blocks (a, indices)
6159end
6260
63- function Base. getindex (a:: GradedUnitRangeDual , indices:: Vector{<:BlockIndexRange{1}} )
61+ function gradedunitrange_getindices (
62+ a:: GradedUnitRangeDual , indices:: Vector{<:BlockIndexRange{1}}
63+ )
6464 return unitrangedual_getindices_blocks (a, indices)
6565end
6666
@@ -79,16 +79,10 @@ function BlockArrays.BlockSlice(b::Block, r::GradedUnitRangeDual)
7979end
8080
8181using NDTensors. LabelledNumbers: LabelledNumbers, LabelledUnitRange, label
82- # The Base version of `length(::AbstractUnitRange)` drops the label.
83- function Base. length (a:: GradedUnitRangeDual{<:Any,<:LabelledUnitRange} )
84- return dual (length (nondual (a)))
85- end
8682function Base. iterate (a:: GradedUnitRangeDual , i)
8783 i == last (a) && return nothing
8884 return dual .(iterate (nondual (a), i))
8985end
90- # TODO : Is this a good definition?
91- Base. unitrange (a:: GradedUnitRangeDual ) = a
9286
9387using NDTensors. LabelledNumbers: LabelledInteger, label, labelled, unlabel
9488using BlockArrays: BlockArrays, blockaxes, blocklasts, combine_blockaxes, findblock
0 commit comments