@@ -62,21 +62,21 @@ BlockedUnitRange(::BlockedUnitRange) = throw(ArgumentError("Forbidden due to amb
6262_blocklengths2blocklasts (blocks) = cumsum (blocks) # extra level to allow changing default cumsum behaviour
6363@inline blockedrange (blocks:: Union{Tuple,AbstractVector} ) = _BlockedUnitRange (_blocklengths2blocklasts (blocks))
6464
65- @inline blockfirsts (a:: BlockedUnitRange ) = [a . first; @views (a . lasts [1 : end - 1 ]) .+ 1 ]
65+ @inline blockfirsts (a:: BlockedUnitRange ) = [first (a) ; @views (blocklasts (a) [1 : end - 1 ]) .+ 1 ]
6666# optimize common cases
6767@inline function blockfirsts (a:: BlockedUnitRange{<:Union{Vector, RangeCumsum{<:Any, <:UnitRange}}} )
68- v = Vector {eltype(a)} (undef, length (a . lasts ))
69- v[1 ] = a . first
70- v[2 : end ] .= @views (a . lasts [oneto (end - 1 )]) .+ 1
68+ v = Vector {eltype(a)} (undef, length (blocklasts (a) ))
69+ v[1 ] = first (a)
70+ v[2 : end ] .= @views (blocklasts (a) [oneto (end - 1 )]) .+ 1
7171 return v
7272end
7373@inline blocklasts (a:: BlockedUnitRange ) = a. lasts
7474
7575_diff (a:: AbstractVector ) = diff (a)
7676_diff (a:: Tuple ) = diff (collect (a))
77- @inline blocklengths (a:: BlockedUnitRange ) = isempty (a . lasts) ? [_diff (a . lasts) ;] : [first (a . lasts) - a . first+ 1 ; _diff (a . lasts )]
77+ @inline blocklengths (a:: BlockedUnitRange ) = isempty (blocklasts (a)) ? [_diff (blocklasts (a)) ;] : [first (blocklasts (a)) - first (a) + 1 ; _diff (blocklasts (a) )]
7878
79- length (a:: BlockedUnitRange ) = isempty (a . lasts) ? 0 : Integer (last (a . lasts) - a . first+ 1 )
79+ length (a:: BlockedUnitRange ) = isempty (blocklasts (a)) ? 0 : Integer (last (blocklasts (a)) - first (a) + 1 )
8080
8181"""
8282 blockisequal(a::AbstractUnitRange{Int}, b::AbstractUnitRange{Int})
@@ -440,24 +440,24 @@ Base.BroadcastStyle(::Type{BlockedUnitRange{R}}) where R = Base.BroadcastStyle(R
440440
441441_blocklengths2blocklasts (blocks:: AbstractRange ) = RangeCumsum (blocks)
442442function blockfirsts (a:: BlockedUnitRange{Base.OneTo{Int}} )
443- a . first == 1 || error (" Offset axes not supported" )
444- Base. OneTo {Int} (length (a . lasts ))
443+ first (a) == 1 || error (" Offset axes not supported" )
444+ Base. OneTo {Int} (length (blocklasts (a) ))
445445end
446446function blocklengths (a:: BlockedUnitRange{Base.OneTo{Int}} )
447- a . first == 1 || error (" Offset axes not supported" )
448- Ones {Int} (length (a . lasts ))
447+ first (a) == 1 || error (" Offset axes not supported" )
448+ Ones {Int} (length (blocklasts (a) ))
449449end
450450function blockfirsts (a:: BlockedUnitRange{<:AbstractRange} )
451- st = step (a . lasts )
452- a . first == 1 || error (" Offset axes not supported" )
453- @assert first (a . lasts) - a . first+ 1 == st
454- range (1 ; step= st, length= length (a . lasts ))
451+ st = step (blocklasts (a) )
452+ first (a) == 1 || error (" Offset axes not supported" )
453+ @assert first (blocklasts (a)) - first (a) + 1 == st
454+ range (1 ; step= st, length= length (blocklasts (a) ))
455455end
456456function blocklengths (a:: BlockedUnitRange{<:AbstractRange} )
457- st = step (a . lasts )
458- a . first == 1 || error (" Offset axes not supported" )
459- @assert first (a . lasts) - a . first+ 1 == st
460- Fill (st,length (a . lasts ))
457+ st = step (blocklasts (a) )
458+ first (a) == 1 || error (" Offset axes not supported" )
459+ @assert first (blocklasts (a)) - first (a) + 1 == st
460+ Fill (st,length (blocklasts (a) ))
461461end
462462
463463
0 commit comments