.where for performing masked operations
- Dominant language
- Kotlin
- Stars
- 734
- Forks
- 51
- Avg merge
- 9h 52m
- Merged PRs (30d)
- 6
Description
This is a follow-up of https://github.com/Kotlin/multik/issues/48
(I think boolean arrays are not implemented yet, so this leaves us at integer array with 0 as false, 1 as true)
In numpy one can do:
```python
np.where(condition, x, y)
```
https://numpy.org/doc/2.2/reference/generated/numpy.where.html
`x` and `y` are "array-like" i.e. can be an array or scalar. The result is an array with `x` where `condition` is true and `y` otherwise.
I guess this can be implemented via `mapIndexed` but it would be nice to have in the stdlib.
Contributor guide
Research direction
Start by reviewing follow-up issue #48 and the existing mapIndexed API in Multik's stdlib. Clarify how integer masks using 0 and 1 should select array or scalar x and y values, then add the operation and coverage for both mask outcomes; done means behavior matches the described NumPy-style selection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100