Skip to content

Commit

Permalink
Update reducedim.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed Dec 18, 2021
1 parent 3a922a1 commit eb47275
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ for (f1, f2, initval, typeextreme) in ((:min, :max, :Inf, :typemax), (:max, :min

if isempty(A1)
# If the slice is empty just return non-view version as the initial array
return copy(A1)
return map(f, A1)
else
# otherwise use the min/max of the first slice as initial value
v0 = mapreduce(f, $f2, A1)
Expand All @@ -148,9 +148,9 @@ for (f1, f2, initval, typeextreme) in ((:min, :max, :Inf, :typemax), (:max, :min
Tr = v0 isa T ? T : typeof(v0)

# but NaNs and missing need to be avoided as initial values
if (v0 == v0) === false
if isnan(v0)
# v0 is NaN
v0 = $initval
v0 = oftype(v0, $initval)
elseif isunordered(v0)
# v0 is missing or a third-party unordered value
Tnm = nonmissingtype(Tr)
Expand Down

0 comments on commit eb47275

Please sign in to comment.