Skip to content

keepdims argument to argmin() and argmax() #109

Closed
@asmeurer

Description

@asmeurer

The argmin and argmax functions require the keepdims keyword argument, same as min and max. However, in NumPy, min and max have this keyword argument, but argmin and argmax do not. We should confirm whether this keyword argument actually makes sense for these functions, or whether it was just added to these functions by mistake because they are also in the non-arg variants.

The description for keepdims is as follows:

keepdims : bool

If True , the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see Broadcasting ). Otherwise, if False , the reduced axes (dimensions) must not be included in the result. Default: False .

Perhaps the reason NumPy doesn't implement this for the arg* functions is that they return indices, so maintaining broadcastability is not important. The documentation for max says (emphasis added):

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

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