Repository navigation
fix: Propagate NaN from CircularDoubleBuffer Max/Min - #2271
Conversation
GetMax/GetMin seeded from physical slot 0 and compared with > / <, so a NaN was returned only when it sat in slot 0 and was ignored anywhere else. They now return NaN when any value in the filled window is NaN, independent of ring position, with no allocation. No hub output changes: bar-fed hubs receive decimal values, and the chained hubs (StochRsi, Stc, FisherTransform) skip NaN before Add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0112YAMNCuDSg5D2UyndEgqi
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
| Duplication | 0 |
🟢 Coverage 100.00% diff coverage · -0.01% coverage variation
Metric Results Coverage variation ✅ -0.01% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (e92f641) 19599 18911 96.49% Head commit (aedc30b) 19649 (+50) 18957 (+46) 96.48% (-0.01%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#2271) 14 14 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Review summary — no actionable findings.
Scope: Tier 2 — Developer, Tester, Inspector, plus an independent pass, over both changed files; CI is green.
- The scan in
GetMax/GetMinis correct: valid entries always occupy slots0.._fill-1, so any NaN in the window (partial, full, or wrapped) now returns NaN, and empty-buffer, ±0, and ±Infinity behavior is unchanged. - The PR's no-parity-change claim holds: StochRsi, Stc, and FisherTransform hubs skip NaN before
Add, and the bar-fed hubs readdecimalfields. - The new tests' slot/window comments are accurate. The two cases that pass on old code (NaN in slot 0) and the eviction test are legitimate regression guards.
Reviewed by the FaciōQuō swarm
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (12)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The extrema change is ready to merge after normal checks; no actionable risk remains in the supplied review evidence. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
CircularDoubleBuffer.GetMax()/GetMin()seeded from physical slot 0 and compared with>/<. Because NaN comparisons are always false, a NaN was returned only when it sat in slot 0 (not necessarily the oldest element after wraparound) and was silently ignored in any other slot.Semantics chosen: any NaN in the filled window →
NaN, independent of ring position. This follows the NaN policy insrc/AGENTS.md("let NaN propagate"). It also matches the canonical Series behavior of the Stoch family (CalcStochexplicitly returns NaN for a NaN in the window, used by Stoch, WilliamsR, StochRsi, and Stc) and of FisherTransform and Chop (Math.Max/Math.Minpropagate NaN). The implementation adds an earlydouble.IsNaNreturn inside the existing scan and allocates nothing.Series parity
No hub's output changes:
decimalbar fields, so the buffer can never hold NaN.Add.So the buffer never receives NaN in production today. This fix makes the utility correct for any future caller; it does not change current results.
Tests
RollingWindow.Tests.csadds tests for NaN at the oldest, middle, and newest positions, both before and after wraparound, plus a partial window and a NaN that has been evicted (results recover). On the old code, 5 of the 7 NaN-in-window tests fail; the 2 that pass are the cases where the NaN sits in physical slot 0.Performance
Stream benchmarks were run for all 11 hubs that use the buffer, comparing old and new code on the same machine.
perf.sh spotflags most of these hubs against the committed baselines. Those baselines come from a different machine, so the flags don't reflect this change.Quality gates
dotnet build(-warnAsError): 0 warnings, 0 errorsdotnet format --verify-no-changes: cleanaudit-streamhub.sh: clean🤖 Generated with Claude Code
https://claude.ai/code/session_0112YAMNCuDSg5D2UyndEgqi