-
Notifications
You must be signed in to change notification settings - Fork 8
Simplify and clarify parts of epi_slide
implementation
#399
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
Conversation
`slider::hop_index` doesn't require starts & stops to be in `.i`, and we aren't actually doing that anyway. Plus comment to help clarify that we're passing the group key to comps via `...`.
Rename `time_values` to `ref_time_values` or `kept_ref_time_values` depending on the context. Does not change the interface of `epi_slide`.
We checked them for nonzero length when we filtered `ref_time_values` down to those present in the `x$time_value`, but now we require `all(ref_time_values %in% unique(x$time_value))`.
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.
Looks great! There are some great simplifications and clarifications here! This chunk is a lot easier to reason about now.
.group_key, # see `?group_modify` | ||
..., # `...` to `epi_slide` forwarded here |
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.
praise: Good to be clear about this. I was confused how .group_key
, though normally expected by the function provided to group_modify
, was being handled (and obfuscated) by ...
.
Abort("The starting and/or stopping times for sliding are out of bounds with respect to the range of times in your data. Check your settings for ref_time_values and align (and before, if specified).") | ||
} | ||
starts <- ref_time_values - before | ||
stops <- ref_time_values + after |
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.
praise: Great simplification!
This is just a few minor refactors, removing some redundant checks, clarifying naming, adding some comments.