Skip to content

min/max/mean of empty arrays (Trac #2078) #2670

Closed

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/2078 on 2012-03-11 by trac user muellner, assigned to unknown.

[]In NumPy release 1.5.1, the minimum/maximum/mean of empty arrays is handled in a sensible way, namely by returning an empty array:

>>> numpy.min(numpy.zeros((0,2)), axis=1)
array([], dtype=float64)

Likewise for max and mean.

This behavior is broken in NumPy 1.7.0.dev-56f66bb, and the line above raises a ValueError. Is this a bug or a feature? Personally, I prefer the old behavior, as it allows the easy handling of special cases (zero-sized arrays) without the need for extra checks.

Activity

  1. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @charris wrote on 2012-03-11

    It would be good to post this question on the numpy mailing list. The handling of empty arrays is something we want to sort out and it would be good to discuss this there.

  2. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @mwiebe wrote on 2012-03-12

    This makes sense to me, it probably changed when I rewrote the ufunc 'reduce' method to optimize its cache-coherency and add NA support. I'm not sure if it's flogging a dead horse to mention that there should have been a unit test for this so it would have been caught during development instead of now.

  3. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    Milestone changed to NumPy 1.7 by @mwiebe on 2012-03-12

  4. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @charris wrote on 2012-03-12

    I think that horse is now one of undead.

  5. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @njsmith wrote on 2012-05-20

    A patch is here, but not making a PR yet because there is a traffic jam there. I'd rather not have 3 conflicting PRs all outstanding at once :-) So noting to make sure it won't get lost.

    njsmith@a0448b8

  6. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @njsmith wrote on 2012-06-27

    #323

  7. numpy-gitbot commented on Oct 19, 2012

    @numpy-gitbot
    Author

    @rgommers wrote on 2012-07-15

    PR was merged.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - BugPriority: highcomponent: numpy._core

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions