Repository navigation
fix: drop nulls in mapNotNull instead of padding with zeros (#355) - #367
Merged
Merged
Conversation
mapNotNull, mapIndexedNotNull and mapMultiIndexedNotNull return a 1D array of the non-null results. mapNotNull and mapMultiIndexedNotNull now return D1Array<R> instead of NDArray<R, D>, as filter does.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The D1Array return-type changes break source compatibility for higher-dimensional callers and conflict with repository guidance, requiring maintainer confirmation of the compatibility exception and migration/release handling.
No open issues 🎉
What changed in this PR
Fixes #355 by making the three NotNull mapping operations drop null results instead of padding with zeros. Results are always 1D, matching filter; this changes the return type of mapNotNull and mapMultiIndexedNotNull and is source-incompatible for callers expecting higher-dimensional results.
Changes:
- Trims result storage to the non-null count and returns
D1Array<R>. - Adds regression tests for filtering, empty results, traversal order, and result types.
- Updates KDoc, API documentation, and synchronized examples.
| File | Description |
|---|---|
| multik-core/src/commonTest/kotlin/samples/docs/apiDocs/arrayOperations.kt | Adds a null-dropping mapping example. |
| multik-core/src/commonTest/kotlin/org/jetbrains/kotlinx/multik/iterable/IterableNDArrayTest.kt | Adds regression coverage for all three operations. |
| multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/ndarray/operations/IteratingNDArray.kt | Compacts results, standardizes 1D output, and documents behavior. |
| docs/topics/gettingStarted/quickstart.md | Adds the mapMultiIndexedNotNull reference link. |
| docs/topics/apiDocs/map.md | Updates signatures, return semantics, and examples. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mapNotNull,mapIndexedNotNullandmapMultiIndexedNotNullreturn only the non-null results instead of padding the tail with zeros. The result is 1D, as withfilter, somapNotNullandmapMultiIndexedNotNullnow returnD1Array<R>instead ofNDArray<R, D>(source-incompatible for D > 1).Fixes #355
Testing
IterableNDArrayTestand doc samples on JVM and macosArm64; new tests on JS (node)apiCheck korroCheckChecklist