Skip to content

Commit c2c64c7

Browse files
authored
limit mapreduce to Integer OffsetUnitRanges (#216)
1 parent 54e12e5 commit c2c64c7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/OffsetArrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ end
373373

374374
# mapreduce is faster with an IdOffsetRange than with an OffsetUnitRange
375375
# We therefore convert OffsetUnitRanges to IdOffsetRanges with the same values and axes
376-
function Base.mapreduce(f, op, As::OffsetUnitRange...; kw...)
376+
function Base.mapreduce(f, op, As::OffsetUnitRange{<:Integer}...; kw...)
377377
ofs = map(A -> first(axes(A,1)) - 1, As)
378-
AIds = map((A, of) -> IdOffsetRange(UnitRange(parent(A) .- of), of), As, ofs)
378+
AIds = map((A, of) -> IdOffsetRange(UnitRange(parent(A)) .- of, of), As, ofs)
379379
mapreduce(f, op, AIds...; kw...)
380380
end
381381

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ end
15211521
@test clamp.(A, (amax+amin)/2, amax) == OffsetArray(clamp.(parent(A), (amax+amin)/2, amax), axes(A))
15221522

15231523
@testset "mapreduce for OffsetRange" begin
1524-
for r in Any[5:100, IdOffsetRange(1:100, 4), IdOffsetRange(4:5), # AbstractUnitRanges
1524+
for r in Any[5:100, UnitRange(5.0, 20.0), IdOffsetRange(1:100, 4), IdOffsetRange(4:5), # AbstractUnitRanges
15251525
2:4:14, 1.5:1.0:10.5, # AbstractRanges
15261526
]
15271527

0 commit comments

Comments
 (0)