-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rust, python): rolling_groupy was returning incorrect results when offset was positive #9082
Changes from all commits
4882a15
dc7bfd2
f5644aa
66b94dd
096b21b
ed54c30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -690,15 +690,15 @@ fn test_rolling_lookback() { | |
) | ||
.unwrap(); | ||
assert_eq!(dates.len(), groups.len()); | ||
assert_eq!(groups[0], [0, 5]); | ||
assert_eq!(groups[1], [1, 5]); | ||
assert_eq!(groups[2], [2, 5]); | ||
assert_eq!(groups[3], [3, 5]); | ||
assert_eq!(groups[4], [4, 5]); | ||
assert_eq!(groups[5], [5, 4]); | ||
assert_eq!(groups[6], [6, 3]); | ||
assert_eq!(groups[7], [7, 2]); | ||
assert_eq!(groups[8], [8, 0]); | ||
assert_eq!(groups[0], [1, 4]); // (00:00, 02:00] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure this test was right to begin with if the dates are: |
||
assert_eq!(groups[1], [2, 4]); // (00:30, 02:30] | ||
assert_eq!(groups[2], [3, 4]); // (01:00, 03:00] | ||
assert_eq!(groups[3], [4, 4]); // (01:30, 03:30] | ||
assert_eq!(groups[4], [5, 4]); // (02:00, 04:00] | ||
assert_eq!(groups[5], [6, 3]); // (02:30, 04:30] | ||
assert_eq!(groups[6], [7, 2]); // (03:00, 05:00] | ||
assert_eq!(groups[7], [8, 1]); // (03:30, 05:30] | ||
assert_eq!(groups[8], [9, 0]); // (04:00, 06:00] | ||
|
||
let period = Duration::parse("2h"); | ||
let tu = TimeUnit::Milliseconds; | ||
|
@@ -708,25 +708,6 @@ fn test_rolling_lookback() { | |
ClosedWindow::Both, | ||
ClosedWindow::None, | ||
] { | ||
let offset = Duration::parse("0h"); | ||
let g0 = groupby_values_iter_full_lookahead( | ||
period, | ||
offset, | ||
&dates, | ||
closed_window, | ||
tu, | ||
None, | ||
0, | ||
None, | ||
) | ||
.collect::<PolarsResult<Vec<_>>>() | ||
.unwrap(); | ||
let g1 = | ||
groupby_values_iter_partial_lookbehind(period, offset, &dates, closed_window, tu, None) | ||
.collect::<PolarsResult<Vec<_>>>() | ||
.unwrap(); | ||
assert_eq!(g0, g1); | ||
|
||
let offset = Duration::parse("-2h"); | ||
let g0 = | ||
groupby_values_iter_full_lookbehind(period, offset, &dates, closed_window, tu, None, 0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we have a nested loop now.
Can we maybe keep the old behavior for
offset= 0
?We can branch on the
offset=?
case and have a loop for both cases.Or don't we hit this path on the
offset=0
case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, thanks - yes, but only if the window is closed on the left (if it's open on the left, then
time[i]
shouldn't be included in the group)