Skip to content

Commit 98d2743

Browse files
committed
Inference fix
Update reducedim.jl
1 parent 0486330 commit 98d2743

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

base/reducedim.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,22 +181,23 @@ function reducedim_init(f::ExtremaMap, op::typeof(_extrema_rf), A::AbstractArray
181181
v0 = reverse(mapreduce(f, op, A1)) # turn minmax to maxmin
182182

183183
T = _realtype(f.f, promote_union(eltype(A)))
184-
Tr = v0[1] isa T && v0[2] isa T ? NTuple{2,T} : typeof(v0)
184+
Tmin = v0[1] isa T ? T : typeof(v0[1])
185+
Tmax = v0[2] isa T ? T : typeof(v0[2])
185186

186187
# but NaNs and missing need to be avoided as initial values
187188
if v0[1] isa Number && isnan(v0[1])
188189
v0 = oftype(v0[1], Inf), oftype(v0[2], -Inf)
189190
elseif isunordered(v0[1])
190191
# v0 is missing or a third-party unordered value
191-
T1, T2 = Tr.parameters
192192
# TODO: Some types, like BigInt, don't support typemin/typemax.
193193
# So a Matrix{Union{BigInt, Missing}} can still error here.
194-
v0 = typemax(nonmissingtype(T1)), typemin(nonmissingtype(T2))
194+
v0 = typemax(nonmissingtype(Tmin)), typemin(nonmissingtype(Tmax))
195195
end
196196
# v0 may have changed type.
197-
Tr = v0[1] isa T && v0[2] isa T ? NTuple{2,T} : typeof(v0)
197+
Tmin = v0[1] isa T ? T : typeof(v0[1])
198+
Tmax = v0[2] isa T ? T : typeof(v0[2])
198199

199-
return reducedim_initarray(A, region, v0, Tr)
200+
return reducedim_initarray(A, region, v0, Tuple{Tmin,Tmax})
200201
end
201202

202203
reducedim_init(f::Union{typeof(abs),typeof(abs2)}, op::typeof(max), A::AbstractArray{T}, region) where {T} =

0 commit comments

Comments
 (0)