You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix off-by-one in OrderedRingBuffer.count_covered and add consistency test (#1343)
### Summary
This PR fixes a subtle off-by-one issue in the
`OrderedRingBuffer.count_covered` method and adds a test to ensure
window count consistency in `MovingWindow`.
### Changes
1. **Fix `count_covered` calculation**
- Switched from floating-point division to integer `timedelta` division
(`timedelta // timedelta`).
- This eliminates rounding errors in sample count calculations and
ensures accurate coverage for all window sizes and sampling periods.
2. **Add `test_moving_window_length`**
- New test verifies that the moving window length is consistent without
resampling.
- Confirms that the count of covered samples matches the expected window
capacity.
- Helps prevent regressions related to off-by-one errors in the future.
### Motivation
Floating-point division could produce off-by-one errors for certain
window sizes and sampling periods, causing `count_covered` to be
inaccurate. Switching to integer-based `timedelta` division ensures
deterministic and exact counts. The new test provides coverage to catch
similar issues.
-`FormulaEngine` and `FormulaEngine3Phase` are now type aliases to `Formula` and `Formula3Phase`, fixing a typing issue introduced in `v1.0.0-rc2202`.
5
+
<!-- Here goes a general summary of what this release is about -->
6
+
7
+
## Upgrading
8
+
9
+
<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
10
+
11
+
## New Features
12
+
13
+
<!-- Here goes the main new features and examples or instructions on how to use them -->
14
+
15
+
## Bug Fixes
16
+
17
+
- Fixed an off-by-one calculation in `OrderedRingBuffer.count_covered` by switching to integer timedelta division, ensuring accurate sample counting for all window sizes and sampling periods.
0 commit comments