Conversation
…orter than window size When Boundary.AtBeginning or Boundary.AtEnding is set and the series length is less than (window size - 1), the incomplete-window index loops would generate out-of-bounds addresses, causing an IndexOutOfRangeException when the vector tries to materialise the window. For AtBeginning: cap the upper bound of the loop at 'length' so no index beyond the last element is ever emitted. For AtEnding: start the loop at max(1, size - length) so that the computed start address (length - size + i) is never negative. Closes #559 Co-authored-by: Copilot <[email protected]>
Member
|
/repo-assist fix broken CI, update R installation process and scripts as needed |
This was referenced Mar 8, 2026
Closed
…unds-2f1e556b1b40f4bb
…unds-2f1e556b1b40f4bb
…unds-2f1e556b1b40f4bb
…unds-2f1e556b1b40f4bb
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.
🤖 This is an automated PR from Repo Assist.
Fixes the
IndexOutOfRangeExceptionreported in #559.Root Cause
Seq.windowRangesWithBoundsinCommon.fsgenerates the incomplete-window address ranges forBoundary.AtBeginningandBoundary.AtEnding. When the series length is less than(window size − 1), the loops produced out-of-bounds indices:for i in 1L .. size - 1L— whenlength = 0this still emits(Incomplete, 0, 0),(Incomplete, 0, 1), … even though there are no elements.for i in 1L .. size - 1L— whenlength < size - 1the computed start addresslength - size + ibecomes negative.These invalid indices reached
ArrayVectorBuilder.Build, which then threw.Fix
AtBeginning — cap the loop upper bound at
length:AtEnding — start the loop at
max 1L (size - length)so the start address is never negative:Both changes are a one-liner and leave the normal (non-degenerate) case unchanged.
Regression Tests
Two new NUnit tests added in
Series.fs:Series.windowSize with AtBeginning does not throw when size exceeds series length— covers empty series (size 1 and 2) and a one-element series with a window of size 3.Series.windowSize with AtEnding does not throw when size exceeds series length— same cases for theAtEndingboundary.Test Status
The library builds successfully (
dotnet build src/Deedle/Deedle.fsproj). The test project targetsnet5.0, which is not available in the current environment (only .NET 8+ installed), so the test suite could not be executed locally. The fix logic was verified manually with F# Interactive against the expected outputs. The tests will run in the project's CI on a net5.0 runner.