@@ -131,6 +131,10 @@ vvminimum(A::AbstractArray) = vvmapreduce(identity, min, typemax, A, :)
131
131
# a custom implementation of extrema is not really worth it, as the time/memory
132
132
# cost is approximately the same. Also, it suffers from first dimension reduction error.
133
133
134
+ # Convenience to handle zipping of results
135
+ _vvextrema_zip (a:: Number , b:: Number ) = a, b
136
+ _vvextrema_zip (a, b) = collect (zip (a, b))
137
+
134
138
"""
135
139
vvextrema(f, A::AbstractArray, dims=:)
136
140
@@ -140,7 +144,7 @@ over the given `dims`.
140
144
# Warning
141
145
`NaN` values are not handled!
142
146
"""
143
- vvextrema (f:: F , A, dims) where {F} = collect ( zip ( vvminimum (f, A, dims), vvmaximum (f, A, dims) ))
147
+ vvextrema (f:: F , A, dims) where {F} = _vvextrema_zip ( vvminimum (f, A, dims), vvmaximum (f, A, dims))
144
148
vvextrema (f:: F , A, :: Colon ) where {F} = (vvminimum (f, A, :), vvmaximum (f, A, :))
145
149
vvextrema (f:: F , A) where {F<: Function } = vvextrema (f, A, :)
146
150
# ::AbstractArray required in order for kwargs interface to work
@@ -260,7 +264,7 @@ of the 2-tuple `init`, which can be any combination of values `<:Number` or func
260
264
which accept a single type argument.
261
265
"""
262
266
vvextrema (f, A; dims= :, init= (typemax, typemin)) =
263
- collect ( zip ( vvmapreduce (f, min, init[1 ], A, dims), vvmapreduce (f, max, init[2 ], A, dims) ))
267
+ _vvextrema_zip ( vvmapreduce (f, min, init[1 ], A, dims), vvmapreduce (f, max, init[2 ], A, dims))
264
268
265
269
"""
266
270
vvextrema(A::AbstractArray; dims=:, init=(typemax, typemin))
@@ -269,7 +273,7 @@ Compute the minimum and maximum values of `A` over the given `dims`,
269
273
with the min and max initialized by `init`.
270
274
"""
271
275
vvextrema (A; dims= :, init= (typemax, typemin)) =
272
- collect ( zip ( vvmapreduce (identity, min, init[1 ], A, dims), vvmapreduce (identity, max, init[2 ], A, dims) ))
276
+ _vvextrema_zip ( vvmapreduce (identity, min, init[1 ], A, dims), vvmapreduce (identity, max, init[2 ], A, dims))
273
277
274
278
275
279
# reduction over all dims
@@ -707,7 +711,7 @@ over the given `dims`.
707
711
# Warning
708
712
`NaN` values are not handled!
709
713
"""
710
- vtextrema (f:: F , A, dims) where {F} = collect ( zip ( vtminimum (f, A, dims), vtmaximum (f, A, dims) ))
714
+ vtextrema (f:: F , A, dims) where {F} = _vvextrema_zip ( vtminimum (f, A, dims), vtmaximum (f, A, dims))
711
715
vtextrema (f:: F , A, :: Colon ) where {F} = (vtminimum (f, A, :), vtmaximum (f, A, :))
712
716
vtextrema (f:: F , A) where {F<: Function } = vtextrema (f, A, :)
713
717
# ::AbstractArray required in order for kwargs interface to work
@@ -823,7 +827,7 @@ of the 2-tuple `init`, which can be any combination of values `<:Number` or func
823
827
which accept a single type argument.
824
828
"""
825
829
vtextrema (f, A; dims= :, init= (typemax, typemin)) =
826
- collect ( zip ( vtmapreduce (f, min, init[1 ], A, dims), vtmapreduce (f, max, init[2 ], A, dims) ))
830
+ _vvextrema_zip ( vtmapreduce (f, min, init[1 ], A, dims), vtmapreduce (f, max, init[2 ], A, dims))
827
831
828
832
"""
829
833
vtextrema(A::AbstractArray; dims=:, init=(typemax, typemin))
@@ -832,7 +836,7 @@ Compute the minimum and maximum values of `A` over the given `dims`,
832
836
with the min and max initialized by `init`.
833
837
"""
834
838
vtextrema (A; dims= :, init= (typemax, typemin)) =
835
- collect ( zip ( vtmapreduce (identity, min, init[1 ], A, dims), vtmapreduce (identity, max, init[2 ], A, dims) ))
839
+ _vvextrema_zip ( vtmapreduce (identity, min, init[1 ], A, dims), vtmapreduce (identity, max, init[2 ], A, dims))
836
840
837
841
# reduction over all dims
838
842
@generated function vtmapreduce (f:: F , op:: OP , init:: I , A:: AbstractArray{T, N} , :: Colon ) where {F, OP, I, T, N}
0 commit comments