Skip to content

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

Closed

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?

Activity

  1. eric-wieser commented on May 12, 2017

    @eric-wieser
    Member

    out also works fine on outer, I'd assume

  2. eric-wieser commented on May 12, 2017

    @eric-wieser
    Member

    I'd favor option 2 for consistency, I think - especially since I'd like to see ufunc.reduce become a gufunc someday

  3. mhvk commented on May 12, 2017

    @mhvk
    ContributorAuthor

    well, option 2 is the easier, so I'll take this as a reason to at least make a PR for it...

  4. mhvk commented on May 12, 2017

    @mhvk
    ContributorAuthor

    See #9106 for an implementation of option 2. Definitely the easier route...

  5. mhvk commented on May 17, 2017

    @mhvk
    ContributorAuthor

    closing this since a fix is now ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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