Skip to content

Commit b35ff37

Browse files
committed
Make OffsetArray maximum! not as type unstable
The change in #50429 moves around some dispatch boundaries and pushes the allocations in the offsetarrays `maximum!` test over the limit. The implementation of that code is massively type unstable. Somewhat, ironically, the whole original point of that test was to test that the implementation was not type-unstable (#28941), so actually opt our OffsetArrays implementation into the interface that's supposed to guarantee that. If this PR is fine here, I'll submit the same upstream to avoid diverging the implementations too much.
1 parent 2360140 commit b35ff37

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

test/offsetarray.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -627,15 +627,15 @@ end
627627
B = OffsetArray(reshape(1:24, 4, 3, 2), -5, 6, -7)
628628
for R in (fill(0, -4:-1), fill(0, -4:-1, 7:7), fill(0, -4:-1, 7:7, -6:-6))
629629
@test @inferred(maximum!(R, B)) == reshape(maximum(B, dims=(2,3)), axes(R)) == reshape(21:24, axes(R))
630-
@test @allocated(maximum!(R, B)) <= 800
630+
@test @allocated(maximum!(R, B)) <= 300
631631
@test @inferred(minimum!(R, B)) == reshape(minimum(B, dims=(2,3)), axes(R)) == reshape(1:4, axes(R))
632-
@test @allocated(minimum!(R, B)) <= 800
632+
@test @allocated(minimum!(R, B)) <= 300
633633
end
634634
for R in (fill(0, -4:-4, 7:9), fill(0, -4:-4, 7:9, -6:-6))
635635
@test @inferred(maximum!(R, B)) == reshape(maximum(B, dims=(1,3)), axes(R)) == reshape(16:4:24, axes(R))
636-
@test @allocated(maximum!(R, B)) <= 800
636+
@test @allocated(maximum!(R, B)) <= 300
637637
@test @inferred(minimum!(R, B)) == reshape(minimum(B, dims=(1,3)), axes(R)) == reshape(1:4:9, axes(R))
638-
@test @allocated(minimum!(R, B)) <= 800
638+
@test @allocated(minimum!(R, B)) <= 300
639639
end
640640
@test_throws DimensionMismatch maximum!(fill(0, -4:-1, 7:7, -6:-6, 1:1), B)
641641
@test_throws DimensionMismatch minimum!(fill(0, -4:-1, 7:7, -6:-6, 1:1), B)

test/testhelpers/OffsetArrays.jl

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ Base.show(io::IO, r::IdOffsetRange) = print(io, IdOffsetRange, "(values=",first(
197197

198198
# Optimizations
199199
@inline Base.checkindex(::Type{Bool}, inds::IdOffsetRange, i::Real) = Base.checkindex(Bool, inds.parent, i - inds.offset)
200+
Base._firstslice(r::IdOffsetRange) = IdOffsetRange(Base._firstslice(r.parent), r.offset)
200201

201202
########################################################################################################
202203
# origin.jl

0 commit comments

Comments
 (0)