@@ -62,21 +62,21 @@ BlockedUnitRange(::BlockedUnitRange) = throw(ArgumentError("Forbidden due to amb
62
62
_blocklengths2blocklasts (blocks) = cumsum (blocks) # extra level to allow changing default cumsum behaviour
63
63
@inline blockedrange (blocks:: Union{Tuple,AbstractVector} ) = _BlockedUnitRange (_blocklengths2blocklasts (blocks))
64
64
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 ]
66
66
# optimize common cases
67
67
@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
71
71
return v
72
72
end
73
73
@inline blocklasts (a:: BlockedUnitRange ) = a. lasts
74
74
75
75
_diff (a:: AbstractVector ) = diff (a)
76
76
_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) )]
78
78
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 )
80
80
81
81
"""
82
82
blockisequal(a::AbstractUnitRange{Int}, b::AbstractUnitRange{Int})
@@ -440,24 +440,24 @@ Base.BroadcastStyle(::Type{BlockedUnitRange{R}}) where R = Base.BroadcastStyle(R
440
440
441
441
_blocklengths2blocklasts (blocks:: AbstractRange ) = RangeCumsum (blocks)
442
442
function 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) ))
445
445
end
446
446
function 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) ))
449
449
end
450
450
function 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) ))
455
455
end
456
456
function 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) ))
461
461
end
462
462
463
463
0 commit comments