Repository navigation
fix: keep the last accumulated value in scan (#356) - #368
Merged
Merged
Conversation
scan, scanIndexed and scanMultiIndexed return all size + 1 values, and scanIndexed passes indices from 0. scan and scanMultiIndexed now return D1Array<R> instead of NDArray<R, D>.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The source-incompatible return-type changes to scan and scanMultiIndexed for multidimensional callers require maintainer confirmation that the API break and its release and migration handling are acceptable.
No open issues 🎉
What changed in this PR
Fixes #356 in Multik’s scan operations by preserving the final accumulated value and using zero-based indices in scanIndexed.
Changes:
- All scan variants return all
size + 1values as a 1D array. The return-type changes toscanandscanMultiIndexedare source-incompatible for multidimensional callers. - Adds regression tests for accumulation, indexing, transposed views, and empty arrays.
- Updates KDoc, API documentation, and matching code samples.
| File | Description |
|---|---|
| multik-core/src/commonTest/kotlin/samples/docs/apiDocs/arrayOperations.kt | Adds indexed and multidimensional scan examples. |
| multik-core/src/commonTest/kotlin/org/jetbrains/kotlinx/multik/iterable/IterableNDArrayTest.kt | Adds assertions covering corrected scan behavior and edge cases. |
| multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/ndarray/operations/IteratingNDArray.kt | Fixes result shapes and indexing; documents the updated contracts. |
| docs/topics/apiDocs/scan.md | Updates signatures, result semantics, and synchronized 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.
scan,scanIndexedandscanMultiIndexedreturn allsize + 1values instead of cutting the result to the source shape, andscanIndexedpasses indices from 0. The result is always 1D, soscanandscanMultiIndexednow returnD1Array<R>instead ofNDArray<R, D>(source-incompatible for D > 1).Fixes #356
Testing
:multik-core:jvmTest;IterableNDArrayTestand doc samples on macosArm64; new tests on JS (node)apiCheck korroCheckChecklist