-
Notifications
You must be signed in to change notification settings - Fork 8
Pass ref time value and group key to epix_slide for tidy computations #317
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
brookslogan
merged 41 commits into
ndefries/epix-slide-pass-reftimevalue-without-env
from
ndefries/epix-slide-dots-rtv
Jun 16, 2023
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
8ee084f
reference group, ref time by changing quo env
nmdefries 267c441
set special arg names in func definition
nmdefries a3b31bd
import env
nmdefries d0fc5b0
describe dots var access
nmdefries d0374a1
basic way to calculate ref_time_value in epi_slide
nmdefries f2f3436
support using ref_time_value in epi_slide computations
nmdefries d1b5d72
drop .real, clean up names
nmdefries a95b2a8
import bind_rows
nmdefries 05c311f
tests
nmdefries cd4c382
add empty rows for all group var combos
nmdefries 51b13a6
add dot prefix to dots arg names
nmdefries 8bfb4d8
add support for and test sliding on ungrouped epi_dfs
nmdefries 5564c0d
speed up slow filter and select steps
nmdefries 22b9b69
tests expect epi_df output
nmdefries 0933801
In `epix_slide` tidyeval, use custom data mask rather than quo env
lcbrooks 4410a39
Merge branch 'ndefries/epix-slide-pass-reftimevalue-without-env' into…
nmdefries e644624
import env
nmdefries feb65b3
some tests expect a tibble
nmdefries 620648e
add placeholders for .x, .group_key, and .rtv
nmdefries e9580d3
test helper function behavior
nmdefries b7d7c53
test reftimevalue access on ungrouped epidf
nmdefries 4aa59cb
Merge branch 'ndefries/epix-slide-dots-rtv' into ndefries/epi-slide-rtv
nmdefries e98e03d
expect output date col as date not double
nmdefries fed6f11
filter result by .real when all_rows == TRUE
nmdefries 9ccfe91
keep .real col from being accessible from user f computation
nmdefries 307fb6e
use custom data mask rather than quo env to match `epix_slide` tidyev…
nmdefries 0b48ea4
test helper function behavior
nmdefries 9db1165
rename inrange... for phony helper dates
nmdefries db00432
ci: set DELPHI_EPIDATA_KEY, from a GitHub Secret
lcbrooks f79bc08
ci: annotate actions explaining differences from usethis output
lcbrooks aeb9a25
cleanup: add renv-related entries to .Rbuildignore
lcbrooks d8a95c7
Merge pull request #313 from cmu-delphi/ndefries/epix-slide-pass-reft…
brookslogan 1d26905
ci: note more edits in comments for GitHub Actions
lcbrooks 572f6e6
Merge pull request #328 from cmu-delphi/lcb/use-api-key
brookslogan a4c19f7
Install `.x` etc. into data masks in same way pronouns are
brookslogan 512f08a
Simplify&flatten epi_slide data mask implementation
brookslogan d22b88b
Describe our pronoun-like objects in `epi_slide` `...` docs
brookslogan 39f4d2d
Merge pull request #318 from cmu-delphi/ndefries/epi-slide-rtv
brookslogan e7c4b8d
Rework NEWS.md about `.ref_time_value` and almost-pronouns available
brookslogan 6039646
Merge remote-tracking branch 'upstream/dev' into ndefries/epix-slide-…
brookslogan e047a4a
Fix grammar in `epix_slide` `...` docs
brookslogan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
^renv$ | ||
^renv\.lock$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^LICENSE\.md$ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
#' @docType package | ||
#' @name epiprocess | ||
NULL | ||
utils::globalVariables(c(".x", ".group_key", ".ref_time_value")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
issue: ([maybe] shared by the old code [or maybe not... keep getting tricked by
eval_tidy
defaultenv
for exprs when using quosures])env()
uses the function execution environment [by default], which handles making.x
,.group_key
, and.ref_time_value
available, but also:quo
availableepipredict
, that used slides but relied on packages not in epiprocess imports nor attached in the user's GlobalEnv. (The GlobalEnv thing saves us in some other cases, but seems like an artifact that suggests that R didn't have proper package import namespacing at one point and relied on everything being attached via Depends:.)I'll push an update for this.
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.
I can see that the helper function example works with your updates and exits with an error with the old code, but I don't understand the difference in scope of the two approaches.
This line
epiprocess/R/grouped_epi_archive.R
Line 380 in e9580d3
top
andbottom
will be accessible to the quosure -- right? So why istime_value_needle
findable?And how is the helper function example
different from
? The issue is more than the fact that we're passing a variable rather than a "raw", unassigned 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.
question: In various places in this package we use
::
to use some (but not all) external functions. Why is that? Like here, we're usingrlang::new_data_mask
but there aren't any conflicting function names inepiprocess
or other imported packages.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 question. We haven't really standardized this yet, and it is probably more of a mix because at some point, in new code, I started to try to favor
::
in our internal code (but favor no::
in examples) based on previous discussion, but never spent the time and effort to refactor to any standard.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.
Sorry, didn't see your first question.
eval_tidy
makes both the data mask and the quosure environment available to the computation. It looks likerlang
probably combines these into a single environment. [In the old approach, the data mask didn't have any of the stuff, and the environment was something like anenv()
with no bindings -> ourf
's execution environment ->slide
execution environment -> archive internal environment -> epiprocess pkg namespace -> epiprocess imports -> stuff leading to the global namespace for backward compatibility reasons with old old R stuff, which saved us in a lot of cases. In the newer approaches, we're putting stuff in the data mask part and leaving the env alone, which lets it get stuff from thehelper
execution environment. Maybe we could have gotten similar results by modifying the first approach to not use the default parent env in theenv()
call, but instead setting its parent to the quosure's originalquo_get_env()
and manually adding bindings for.x
etc. like you did in even older versions.]Created on 2023-06-15 by the reprex package (v2.0.1)
Also, I don't think we can use
as_data_pronoun
for.ref_time_value
, it's going to mess up the type, and I don't see what the benefit is anyway.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.
Okay, looking at this again, I think I overcomplicated it with the top & bottom. I think maybe we should be "installing" our pronoun-like objects into the data mask in the same way as regular pronouns. And regardless, we may need to document differences between the actual-pronoun .data vs. the non-pronoun .x. I'll test this out.
Question: what do you think about disallowing
.
in the formula interface? We're faced with.
meaning something different in formulas vs. tidyeval, or meaning something different between slides and mutate/etc. We can't make these all consistent, but we can decide on whether the inconsistency is between two different non-error behaviors, one thing working & the other forbidden, or both forbidden.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.
I thought we wanted
.
to be available in the formula interface so that it matches standard formula behavior, i.e. with access to the first arg via.
,.x
, and..1
. (In reality, I'm not sure.
will be used much.).
by itself doesn't mean anything in tidy expressions, right? It's just a prefix to some pronoun/var names. Unless there's a subtlety I'm missing, it doesn't seem inconsistent or confusing to me.