Skip to content

Handle rolling std window<2 without runtime warnings#69

Merged
joedursun merged 1 commit into
massive-com:masterfrom
shuofengzhang:fix-rolling-std-window-one
Mar 18, 2026
Merged

Handle rolling std window<2 without runtime warnings#69
joedursun merged 1 commit into
massive-com:masterfrom
shuofengzhang:fix-rolling-std-window-one

Conversation

@shuofengzhang

Copy link
Copy Markdown
Contributor

What changed

  • Added an explicit window < 2 guard in _rolling_std to return an all-NaN result immediately.
  • Expanded the _rolling_std docstring to clarify the sample-std (ddof=1) behavior for undersized windows.
  • Tightened test_window_1_returns_nan to assert the undefined window=1 case returns all NaN values.

Why

  • Sample standard deviation with ddof=1 is undefined for window sizes below 2.
  • The previous implementation still called np.std(..., ddof=1) for window=1, which emitted runtime warnings during tests.
  • Returning early keeps behavior mathematically correct and removes avoidable warning noise.

Testing

  • scripts/clone_and_test.sh massive-com/mcp_massive (583 passed)

@joedursun joedursun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @shuofengzhang!

@joedursun
joedursun merged commit 9175d65 into massive-com:master Mar 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants