Skip to content

BUG __array_ufunc__ does not work well with output set on reduce, accumulate, reduceat #9105

@mhvk

Description

@mhvk

As noted by @eric-wieser in #9104 (comment), currently __array_ufunc__ does not actually work as advertised if out is set on anything but __call__: if it is, it is turned into a tuple, but if that is passed back to the regular non-overriden ufunc, one gets an error, since those do not know how to deal with tuples.

Two possible solutions:

  1. We break the "out is always a tuple" rule for reduce, accumulate, reduceat; if we do this, my sense would be to give up the whole tuple idea for nout=1, and just do it only for nout>1...
  2. We allow passing in of tuples in the ufunc.reduce, ufunc.accumulate, and ufunc.reduceat methods.

I think I slightly favour option 1 even though I definitely have argued differently before.

p.s. Interesting how quickly reality hits!

@pv, @njsmith, @charris, @eric-wieser - suggestions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions