Skip to content

Commit 0396151

Browse files
authored
version limit OffsetUnitRange mapreduce (#293)
1 parent 82a0026 commit 0396151

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/OffsetArrays.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,15 @@ if eltype(IIUR) === Int
569569
Base.map(::Type{T}, r::IdentityUnitRange) where {T<:Real} = _indexedby(map(T, UnitRange(r)), axes(r))
570570
end
571571

572-
# mapreduce is faster with an IdOffsetRange than with an OffsetUnitRange
573-
# We therefore convert OffsetUnitRanges to IdOffsetRanges with the same values and axes
574-
function Base.mapreduce(f, op, A1::OffsetUnitRange{<:Integer}, As::OffsetUnitRange{<:Integer}...; kw...)
575-
As = (A1, As...)
576-
ofs = map(A -> first(axes(A,1)) - 1, As)
577-
AIds = map((A, of) -> IdOffsetRange(_subtractoffset(parent(A), of), of), As, ofs)
578-
mapreduce(f, op, AIds...; kw...)
572+
if VERSION < v"1.7.2"
573+
# mapreduce is faster with an IdOffsetRange than with an OffsetUnitRange on Julia 1.6
574+
# We therefore convert OffsetUnitRanges to IdOffsetRanges with the same values and axes
575+
function Base.mapreduce(f, op, A1::OffsetUnitRange{<:Integer}, As::OffsetUnitRange{<:Integer}...; kw...)
576+
As = (A1, As...)
577+
ofs = map(A -> first(axes(A,1)) - 1, As)
578+
AIds = map((A, of) -> IdOffsetRange(_subtractoffset(parent(A), of), of), As, ofs)
579+
mapreduce(f, op, AIds...; kw...)
580+
end
579581
end
580582

581583
# Optimize certain reductions that treat an OffsetVector as a list

0 commit comments

Comments
 (0)