Skip to content

docs: explain fill-value propagation in where - #987

Merged
hameerabbasi merged 1 commit into
pydata:mainfrom
Doribelove:codex/fill-value-where-docs
Oct 9, 2026
Merged

hameerabbasi merged 1 commit into
pydata:mainfrom
Doribelove:codex/fill-value-where-docs

Conversation

@Doribelove

Copy link
Copy Markdown
Contributor

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • 🪄 Feature
  • 🐞 Bug Fix
  • 🔧 Optimization
  • 📚 Documentation
  • 🧪 Test
  • 🛠️ Other

Related issues

Closes #871.

Checklist

  • Code follows style guide
  • Tests added (executable docstring examples)
  • Documented the changes

Please explain your changes below.

Explain in the COO examples that element-wise operations compute the output fill value by applying the operation to the input fill values, with scalars contributing their own values. This replaces the previous description in terms of a dense result.

Add both np.where cases from #871, showing the comparison's boolean fill value, the resulting COO fill value and the dense values. On an identity array with fill value zero, replacing ones with NaN preserves the implicit zeros; replacing values less than one changes the implicit zeros to NaN. No runtime behavior changes.

Validation on main at 6aaba13fa7951da0ea4a656cb10b2c103fbb7035, using Python 3.12.14 and NumPy 2.5.3:

  • python -m pytest --doctest-modules sparse/numba_backend/_coo/core.py -o addopts='' -q: 24 passed, 1 skipped.
  • pre-commit run --all-files: passed.
  • mkdocs build: passed, including execution of the configured tutorial examples. The non-strict build emits parameter-reference, duplicate-anchor and dependency/kernel warnings outside the added examples.
  • git diff --check: passed.

Prepared with OpenAI Codex assistance; the examples and checks above were executed locally against this checkout.

Clarify how element-wise operations determine their output fill value and
illustrate both boolean fill-value branches of np.where from issue pydata#871.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
Signed-off-by: 李永祺 <[email protected]>
@hameerabbasi
hameerabbasi merged commit 779a4cb into pydata:main Oct 9, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage: confused by np.where behaviour and fill_value

2 participants