Skip to content

Commit 847ff9d

Browse files
Merge pull request #1621 from AayushSabharwal/as/fix-mapreduce
fix: use sane `mapreduce` method
2 parents fc1dda9 + 127efbc commit 847ff9d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/array-lib.jl

Lines changed: 13 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,15 @@ 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; kw...)
395+
mapreduce($f, $g, x; kw...)
396+
end false
397+
@eval @wrapped function (::$(typeof(ff)))(f::Function, x::AbstractArray; kw...)
398+
mapreduce(f, $g, x; kw...)
399+
end false
400+
end

0 commit comments

Comments
 (0)