numpy / numpy/numpy

Possible generalization of gufunc keepdims for multiple outputs

Open
#11,118 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

23 - Wish List component: numpy._core
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

#11098 introduced a keepdims argument for gufuncs for which all the inputs had the same number of core dimensions and all the outputs had none; for those, it would insert dimensions of length 1 in the outputs, i.e., a signature like (i),(i)->(),() is changed to (i),(i)->(1),(1).

In https://github.com/numpy/numpy/pull/11098#discussion_r189335102, @eric-wieser wondered whether it should also support signatures like (i),(i)->(),(i), i.e., allow outputs with the same number of dimensions as the inputs as well as those with no core dimensions. This issue is to remind us of this suggestion.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading PR #11098 and the linked discussion at discussion_r189335102 to understand the existing gufunc keepdims behavior. Compare the supported signature (i),(i)->(),() with the proposed (i),(i)->(),(i) case, then identify the relevant gufunc implementation and tests. Done means agreeing on the generalization and covering its behavior with tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.