Skip to content

Commit

Permalink
Change reduced_index for Slices and add test for previously failing
Browse files Browse the repository at this point in the history
maximum of OffsetArray example
  • Loading branch information
andreasnoack committed Jul 13, 2018
1 parent fe68641 commit 0c1137c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# for reductions that expand 0 dims to 1
reduced_index(i::OneTo) = OneTo(1)
reduced_index(i::Slice) = Slice(first(i):first(i))
reduced_index(i::Slice) = first(i):first(i)
reduced_index(i::AbstractUnitRange) =
throw(ArgumentError(
"""
Expand Down
5 changes: 5 additions & 0 deletions test/offsetarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,8 @@ module SimilarUR
@test_throws MethodError similar(a, Float64, (ur,))
@test_throws MethodError similar(a, (2.0,3.0))
end

@testset "Issue 28101" begin
A = OffsetArray(reshape(16:-1:1, (4, 4)), (-3,5))
@test maximum(A, dims=1) == OffsetArray(maximum(parent(A), dims=1), A.offsets)
end

0 comments on commit 0c1137c

Please sign in to comment.