Skip to content

ENH: Add where= parameter support to np.ptp for consistency with other reductions #29675

@KAVYANSHTYAGI

Description

@KAVYANSHTYAGI

Proposed new feature or change:

Currently, numpy.ptp (peak-to-peak: max - min) does not accept the where argument, unlike other reduction functions such as sum, min, max, and mean.

This creates an inconsistency in the API and forces users to pre-mask arrays (e.g., x[mask]) when selectively computing the range of values.

Proposed Enhancement

Extend np.ptp to accept a where parameter, consistent with other reductions. The where mask will be forwarded to both the underlying maximum and minimum reductions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions