Skip to content

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

Merged
merged 5 commits into from
Jan 19, 2024

Conversation

brookslogan
Copy link
Contributor

This is just a few minor refactors, removing some redundant checks, clarifying naming, adding some comments.

`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))`.
Copy link
Contributor

@nmdefries nmdefries left a 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.

Comment on lines +245 to +246
.group_key, # see `?group_modify`
..., # `...` to `epi_slide` forwarded here
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Great simplification!

@nmdefries nmdefries merged commit c0826b8 into ndefries/f-wrapper-speedup-factory Jan 19, 2024
@nmdefries nmdefries deleted the epi_slide_tidy branch January 19, 2024 21:51
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