numpy / numpy/numpy

ENH: provide default value for `less`, `greater`, etc when used with `where`

Open
#21,414 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

01 - Enhancement component: numpy.ufunc
Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Proposed new feature or change:

It would be convenient to do something like:

np.less(a, b, where=c, out=False)

instead of something like

default = np.zeros_like(a, dtype=bool)
np.less(a, b, where=c, out=default)

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 at the np.less ufunc entry point and inspect how where and out are currently handled, along with existing tests for masked ufunc operations. Compare the proposed default-value behavior with the current out workaround and define consistent behavior for less, greater, and related operations before adding coverage that verifies the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.