Skip to content

Commit e149bac

Browse files
fix: use sane mapreduce method
1 parent b14a1dd commit e149bac

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/array-lib.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ end
372372
Term{Any}(_mapreduce, [f, g, x, dims, (kw...,)]))
373373
end false
374374

375-
for (ff, opts) in [sum => (identity, +, false),
376-
prod => (identity, *, true),
375+
for (ff, opts) in [
377376
any => (identity, (|), false),
378377
all => (identity, (&), true)]
379378

@@ -387,3 +386,17 @@ for (ff, opts) in [sum => (identity, +, false),
387386
mapreduce(f, $g, x, dims=dims, init=init)
388387
end false
389388
end
389+
390+
for (ff, opts) in [sum => (identity, +),
391+
prod => (identity, *)]
392+
393+
f, g = opts
394+
@eval @wrapped function (::$(typeof(ff)))(x::AbstractArray;
395+
dims=:, kw...)
396+
mapreduce($f, $g, x, dims=dims, kw...)
397+
end false
398+
@eval @wrapped function (::$(typeof(ff)))(f::Function, x::AbstractArray;
399+
dims=:, kw...)
400+
mapreduce(f, $g, x, dims=dims, kw...)
401+
end false
402+
end

0 commit comments

Comments
 (0)