From 0c1137c4d385b766d5983c2900d49192cf1b4929 Mon Sep 17 00:00:00 2001 From: Andreas Noack Date: Fri, 13 Jul 2018 23:33:23 +0200 Subject: [PATCH] Change reduced_index for Slices and add test for previously failing maximum of OffsetArray example --- base/reducedim.jl | 2 +- test/offsetarray.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/reducedim.jl b/base/reducedim.jl index a2770542826b3..150b93c7e8f5a 100644 --- a/base/reducedim.jl +++ b/base/reducedim.jl @@ -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( """ diff --git a/test/offsetarray.jl b/test/offsetarray.jl index 961f0deb5efed..38a0166441a54 100644 --- a/test/offsetarray.jl +++ b/test/offsetarray.jl @@ -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