-
-
Notifications
You must be signed in to change notification settings - Fork 8
id as names #232
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
id as names #232
Changes from 2 commits
Commits
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
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 |
|---|---|---|
|
|
@@ -24,8 +24,8 @@ | |
| ) | ||
| } | ||
|
|
||
| x_id <- get_code_attr(x, "id") | ||
| y_id <- get_code_attr(y, "id") | ||
| x_id <- names(x@code) | ||
| y_id <- names(y@code) | ||
|
|
||
| shared_ids <- intersect(x_id, y_id) | ||
| if (length(shared_ids) == 0) { | ||
|
|
@@ -89,7 +89,7 @@ c.qenv <- function(...) { | |
| stop(join_validation) | ||
| } | ||
|
|
||
| x@code <- union(x@code, y@code) | ||
| x@code <- utils::modifyList(x@code, y@code) | ||
|
|
||
| # insert (and overwrite) objects from y to x | ||
| [email protected] <- rlang::env_clone([email protected], parent = parent.env(.GlobalEnv)) | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -4,18 +4,18 @@ | |
| #' @name qenv-class | ||
| #' @rdname qenv-class | ||
| #' @slot .xData (`environment`) environment with content was generated by the evaluation | ||
| #' @slot code (`list` of `character`) representing code necessary to reproduce the environment. | ||
| #' @slot code (`named list` of `character`) representing code necessary to reproduce the environment. | ||
| #' Read more in Code section. | ||
| #' of the `code` slot. | ||
| #' | ||
| #' @section Code: | ||
| #' | ||
| #' Each code element is a character representing one call. Each element has possible attributes: | ||
| #' - `warnings` (`character`) the warnings output when evaluating the code element | ||
| #' - `messages` (`character`) the messages output when evaluating the code element | ||
| #' - `id (`integer`) random identifier of the code element to make sure uniqueness when joining | ||
| #' Each code element is a character representing one call. Each element is named with the random | ||
| #' identifier to make sure uniqueness when joining. Each element has possible attributes: | ||
| #' - `warnings` (`character`) the warnings output when evaluating the code element. | ||
| #' - `messages` (`character`) the messages output when evaluating the code element. | ||
| #' - `dependency` (`character`) names of objects that appear in this call and gets affected by this call, | ||
| #' separated by `<-` (objects on LHS of `<-` are affected by this line, and objects on RHS are affecting this line) | ||
| #' separated by `<-` (objects on LHS of `<-` are affected by this line, and objects on RHS are affecting this line). | ||
| #' | ||
| #' @keywords internal | ||
| #' @exportClass qenv | ||
|
|
@@ -54,10 +54,7 @@ setMethod( | |
| #' @name qenv-class | ||
| #' @keywords internal | ||
| setValidity("qenv", function(object) { | ||
| ids <- lapply(object@code, "attr", "id") | ||
| if (any(sapply(ids, is.null))) { | ||
| "All @code slots must have an 'id' attribute" | ||
| } else if (any(duplicated(unlist(ids)))) { | ||
| if (any(duplicated(names(object@code)))) { | ||
| "@code contains duplicated 'id' attributes." | ||
| } else if (!environmentIsLocked([email protected])) { | ||
| "@.xData must be locked." | ||
|
|
||
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.
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 |
|---|---|---|
|
|
@@ -6,10 +6,7 @@ testthat::test_that("Concatenate two identical qenvs outputs", { | |
| q12 <- concat(q1, q2) | ||
|
|
||
| testthat::expect_equal([email protected], [email protected]) | ||
| testthat::expect_identical( | ||
| unlist(q12@code), | ||
| c("iris1 <- iris", "iris1 <- iris") | ||
| ) | ||
| testthat::expect_identical(get_code(q12), "iris1 <- iris\niris1 <- iris") | ||
| }) | ||
|
|
||
| testthat::test_that("Concatenate two independent qenvs results in object having combined code and environments", { | ||
|
|
@@ -22,13 +19,8 @@ testthat::test_that("Concatenate two independent qenvs results in object having | |
| q12 <- concat(q1, q2) | ||
|
|
||
| testthat::expect_equal([email protected], list2env(list(iris1 = iris, mtcars1 = mtcars))) | ||
| testthat::expect_identical( | ||
| unlist(q12@code), | ||
| c("iris1 <- iris", "mtcars1 <- mtcars") | ||
| ) | ||
| q12_ids <- unlist(lapply(q12@code, "attr", "id")) | ||
| q1_q2_ids <- c(attr(q1@code[[1]], "id"), attr(q2@code[[1]], "id")) | ||
| testthat::expect_identical(q12_ids, q1_q2_ids) | ||
| testthat::expect_identical(get_code(q12), "iris1 <- iris\nmtcars1 <- mtcars") | ||
| testthat::expect_identical(names(q12@code), c(names(q1@code), names(q2@code))) | ||
| }) | ||
|
|
||
| testthat::test_that("Concatenate qenvs results with the same variable, the RHS has priority", { | ||
|
|
@@ -59,7 +51,7 @@ testthat::test_that("Concatenate two independent qenvs with warnings results in | |
| q12 <- concat(q1, q2) | ||
|
|
||
| testthat::expect_equal( | ||
| unlist(lapply(q12@code, attr, "warning")), | ||
| unlist(lapply(q12@code, attr, "warning"), use.names = FALSE), | ||
| c( | ||
| "> This is warning 1\n", | ||
| "> This is warning 2\n" | ||
|
|
@@ -74,7 +66,7 @@ testthat::test_that("Concatenate two independent qenvs with messages results in | |
| q12 <- concat(q1, q2) | ||
|
|
||
| testthat::expect_equal( | ||
| unlist(lapply(q12@code, attr, "message")), | ||
| unlist(lapply(q12@code, attr, "message"), use.names = FALSE), | ||
| c( | ||
| "> This is message 1\n", | ||
| "> This is message 2\n" | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.