Skip to content
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

names labels #246

Merged
merged 21 commits into from
Jun 22, 2018
Merged

names labels #246

merged 21 commits into from
Jun 22, 2018

Conversation

acoppock
Copy link
Collaborator

@acoppock acoppock commented Jun 21, 2018

closes #220
closes #227
closes #246

@graemeblair graemeblair changed the title Names labels WIP names labels Jun 21, 2018
# auto_steps <- sapply(lhs, function(x) { lbl <- attr(x, "label"); !is.null(lbl) && grepl("Autogenerated by ", lbl) })
auto_steps <- sapply(lhs, function(x) !is_null(attr(x, "auto-generated")))

auto_steps <- sapply(lhs, function(x) !is_null(attr(x, "auto-generated")))
Copy link
Contributor

Choose a reason for hiding this comment

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

pull out predicate to helper file, rewrite as Filter(Negate(is_autogenerated), lhs)

Copy link
Member

Choose a reason for hiding this comment

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

thx. couldn't get this to work. tried:

is_autogenerated <- function(steps) {
sapply(steps, attr, "auto-generated")
}

lhs <- Filter(Negate(is_autogenerated), lhs)

am I missing something?

@@ -128,31 +119,19 @@
construct_design <- function(...) {

qs <- quos(...)
qs <- maybe_add_names_qs(qs)
Copy link
Contributor

Choose a reason for hiding this comment

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

note that you don't really use qnames now, can probably purge this and set names(ret) directly.

Copy link
Member

Choose a reason for hiding this comment

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

we do that a bit lower, but need here to capture names like pop when sent to pop + declare_sampling(n = 50). the name pop is lost if you don't use maybe_add_names on the quosures.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's only one place that calls in to conduct_design, should not need any NSE within it - pass the steps directly. See #249

# it will fail to evaluate - we can catch that and try to curry it

#' @importFrom rlang quos lang_fn lang_modify eval_tidy
callquos_to_step <- function(step_call, label="") {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

if (is.null(step_meta <- attr(step_j, "step_meta"))) next;
if (attr(step_j, "step_type") == "assignment") {
if (any(step_meta$assignment_variables %in% attr(step, "step_meta")$assignment_variables)) {
# warning("Attempting to inject a `declare_reveal(", this_step_meta$outcome_variables, ", ",
Copy link
Contributor

Choose a reason for hiding this comment

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

The warnings should probably come back at some point.

Copy link
Member

Choose a reason for hiding this comment

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

thx, yes, will remember to come back to this

". You can name steps within declare design, e.g. declare_design(my_pop = pop_step)."), call. = FALSE)
if (names(quotations)[i] == ""){
names(quotations)[i] <- namer(quotations[[i]])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

whole loop can be vectorized now.

@graemeblair graemeblair changed the title WIP names labels names labels Jun 21, 2018
@nfultz
Copy link
Contributor

nfultz commented Jun 21, 2018

See #249

@@ -84,6 +84,7 @@ test_that("sims expansion is correct",{


test_that("fan_out ids are correct",{
sleep_large <- resample_data(sleep, N = 200)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this used anywhere?

Copy link
Member

Choose a reason for hiding this comment

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

that test fails intermittently, was trying to see if upping sample size would help

Copy link
Member

Choose a reason for hiding this comment

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

oic I didn't actually implement. commit to follow

stop("The right hand side does not appear to be a DeclareDesign object or a function", call. = FALSE)
}
while(new_nm %in% union(names(lhs), names(rhs)))
new_nm <- paste0(new_nm, "._")
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to add numbers like data.frame does.

Copy link
Member

Choose a reason for hiding this comment

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

great, just made commits along these lines

@graemeblair
Copy link
Member

think this is good to go, subject to @nfultz review

@coveralls
Copy link

coveralls commented Jun 21, 2018

Coverage Status

Coverage decreased (-0.7%) to 94.627% when pulling 6902c3c on names-labels into c8ce443 on master.

@graemeblair graemeblair merged commit 777300d into master Jun 22, 2018
@graemeblair graemeblair deleted the names-labels branch June 22, 2018 16:57
@graemeblair graemeblair mentioned this pull request Jun 22, 2018
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.

Better default names add name to step when auto injecting reveal step
4 participants