-
Notifications
You must be signed in to change notification settings - Fork 0
Add methods for generating colors for clone IDs. #172
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0cedb62
Add methods for generating colors for clone IDs.
aholmes 438447a
Correct errors in clone color methods. Add tests.
aholmes 1088f5b
Add tests for `get.colours(...)`
aholmes 35b1c9a
modified get.clone.colours.in.order to use get.colours
whelena 2e22ac3
remove unused arguments in get.clone.colours.in.order
whelena 87dfe10
update documentation
whelena 79c6446
Simplify "get.clone.colours" methods.
aholmes c754b9a
add back get.colours
whelena 578ddbb
Merge `get.clone.colours` with `get.colours` and update associated code.
aholmes 3c9d080
Fix lintr errors.
aholmes d809938
Merge branch 'aholmes-add-clone-color-methods' of https://github.com/…
whelena fa8e4df
rename documentation
whelena d6c2d33
Change order of parameters in colour functions to be consistent.
aholmes 4a02cf4
Remove man page.
aholmes eb0c442
lintr fixes.
aholmes 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 |
|---|---|---|
|
|
@@ -28,3 +28,4 @@ Suggests: | |
| VignetteBuilder: knitr | ||
| LazyLoad: yes | ||
| LazyData: yes | ||
| RoxygenNote: 7.3.1 | ||
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 |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| expect.character.vector <- function(result) { | ||
| expect_true(identical(names(result), character(0))); | ||
| expect_true(identical(result, setNames(character(0), character(0)))); | ||
| expect_equal(length(result), 0); | ||
| } | ||
|
|
||
| test_that('get.colours returns a color for each vector element', { | ||
| value.list <- c('ABC', 'DEF', 'DEF', 'GHI'); | ||
| colors <- get.colours(value.list); | ||
| expect_equal(names(colors), c('ABC', 'DEF', 'DEF', 'GHI')); | ||
| expect_equal(length(colors), 4); | ||
| for (i in seq_along(colors)) { | ||
| color.value <- colors[i]; | ||
| expect_true(!is.na(color.value) && nzchar(color.value)); | ||
| } | ||
| }); | ||
|
|
||
| test_that('get.colours returns a color for each vector element when return.names is FALSE', { | ||
| value.list <- c('ABC', 'DEF', 'DEF', 'GHI'); | ||
| colors <- get.colours(value.list, FALSE); | ||
| expect_equal(names(colors), c('ABC', 'DEF', 'DEF', 'GHI')); | ||
| expect_equal(length(colors), 4); | ||
| for (i in seq_along(colors)) { | ||
| color.value <- colors[i]; | ||
| expect_true(!is.na(color.value) && nzchar(color.value)); | ||
| } | ||
| }); | ||
|
|
||
| test_that('get.colours returns a color for unique vector elements when return.names is TRUE', { | ||
| value.list <- c('ABC', 'DEF', 'DEF', 'GHI'); | ||
| colors <- get.colours(value.list, TRUE); | ||
| expect_equal(names(colors), c('ABC', 'DEF', 'GHI')); | ||
| expect_equal(length(colors), 3); | ||
| unique.colors <- unique(names(colors)); | ||
| for (key in unique.colors) { | ||
| expect_true(!is.na(colors[key]) && nzchar(colors[key])); | ||
| } | ||
| }); | ||
|
|
||
| test_that('get.colours returns an empty color vector when value.list is empty', { | ||
| value.list <- c(); | ||
| colors <- get.colours(value.list); | ||
| expect_true(identical(names(colors), character(0))); | ||
| expect_true(identical(colors, setNames(character(0), character(0)))); | ||
| expect_equal(length(colors), 0); | ||
| }); | ||
|
|
||
| test_that('get.colours returns an empty color vector when value.list is empty and return.names is FALSE', { | ||
| value.list <- c(); | ||
| colors <- get.colours(value.list, FALSE); | ||
| expect_true(identical(names(colors), character(0))); | ||
| expect_true(identical(colors, setNames(character(0), character(0)))); | ||
| expect_equal(length(colors), 0); | ||
| }); | ||
|
|
||
| test_that('get.colours returns an empty color vector when value.list is empty and return.names is TRUE', { | ||
| value.list <- c(); | ||
| colors <- get.colours(value.list, TRUE); | ||
| expect_true(identical(names(colors), character(0))); | ||
| expect_true(identical(colors, setNames(character(0), character(0)))); | ||
| expect_equal(length(colors), 0); | ||
| }); | ||
|
|
||
| test_that( | ||
| 'get.colours returns expected vectors', { | ||
| result <- get.colours(NULL, predetermined.colours = NULL); | ||
| expect.character.vector(result); | ||
| result <- get.colours(c('ABC', 'DEF'), predetermined.colours = NULL); | ||
| expect_equal(names(result), c('ABC', 'DEF')); | ||
| expect_true(!is.na(result['ABC']) && nzchar(result['ABC'])); | ||
| expect_true(!is.na(result['DEF']) && nzchar(result['DEF'])); | ||
| result <- get.colours(NULL, predetermined.colours = c('red','green')); | ||
| expect.character.vector(result); | ||
| result <- get.colours(c(), predetermined.colours = c()); | ||
| expect.character.vector(result); | ||
| result <- get.colours(NULL, predetermined.colours = c()); | ||
| expect.character.vector(result); | ||
| result <- get.colours(c(), predetermined.colours = NULL); | ||
| expect.character.vector(result); | ||
| result <- get.colours(c('ABC', 'DEF'), predetermined.colours = c()) | ||
| expect_equal(names(result), c('ABC', 'DEF')); | ||
| expect_true(!is.na(result['ABC']) && nzchar(result['ABC'])); | ||
| expect_true(!is.na(result['DEF']) && nzchar(result['DEF'])); | ||
| result <- get.colours(c(), predetermined.colours = c('red', 'green')); | ||
| expect.character.vector(result); | ||
| result <- get.colours(c('ABC','DEF'), predetermined.colours = c('red','green')); | ||
| expect_equal(result, c(ABC = 'red', DEF = 'green')); | ||
| result <- get.colours(c('ABC','DEF'), predetermined.colours = c('red')); | ||
| expect_equal(names(result), c('ABC', 'DEF')); | ||
| expect_true(result['ABC'] == 'red'); | ||
| expect_true(!is.na(result['DEF']) && nzchar(result['DEF'])); | ||
| result <- get.colours(c('ABC','DEF'), predetermined.colours = c(NULL,'red')); | ||
| expect_equal(names(result), c('ABC', 'DEF')); | ||
| expect_true(result['ABC'] == 'red'); | ||
| expect_true(!is.na(result['DEF']) && nzchar(result['DEF'])); | ||
| result <- get.colours(c('ABC','DEF'), predetermined.colours = c('red',NULL)); | ||
| expect_equal(names(result), c('ABC', 'DEF')); | ||
| expect_true(result['ABC'] == 'red'); | ||
| expect_true(!is.na(result['DEF']) && nzchar(result['DEF'])); | ||
| result <- get.colours(c('ABC'), predetermined.colours = c('red','green')); | ||
| expect_equal(result, c(ABC = 'red')); | ||
| result <- get.colours(c(NULL,'ABC'), predetermined.colours = c('red','green')); | ||
| expect_equal(result, c(ABC = 'red')); | ||
| result <- get.colours(c('ABC',NULL), predetermined.colours = c('red','green')); | ||
| expect_equal(result, c(ABC = 'red')); | ||
| }); | ||
|
|
||
| test_that( | ||
| 'get.colours returns expected vectors with minimum colours specified', { | ||
| result <- get.colours(NULL, predetermined.colours = NULL) | ||
| expect.character.vector(result); | ||
| result <- get.colours(NULL, predetermined.colours = c('red', 'green')) | ||
| expect.character.vector(result); | ||
| result <- get.colours(NULL, predetermined.colours = c('red')) | ||
| expect.character.vector(result); | ||
| result <- get.colours(c('ABC','DEF'), predetermined.colours = c('red', 'green')) | ||
| expect_equal(result, c(ABC = 'red', DEF = 'green')); | ||
| result <- get.colours(c('ABC','DEF'), predetermined.colours = c('red')) | ||
| expect_equal(names(result), c('ABC', 'DEF')); | ||
| expect_true(result['ABC'] == 'red'); | ||
| expect_true(!is.na(result['DEF']) && nzchar(result['DEF'])); | ||
| result <- get.colours(c('ABC'), predetermined.colours = c('red', 'green')) | ||
| expect_equal(result, c(ABC = 'red')); | ||
| }); | ||
|
|
||
| test_that( | ||
| 'get.colours.in.order returns expected vectors when order is not specified', { | ||
| # get.colours.in.order has same result as get.colours | ||
| # with the change that a named list is returned with two members | ||
| result <- get.colours.in.order(NULL, predetermined.colours = NULL) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c('ABC', 'DEF'), predetermined.colours = NULL) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(NULL, predetermined.colours = c('red','green')) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c(), predetermined.colours = c()) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c(), predetermined.colours = NULL) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(NULL, predetermined.colours = c()) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c('ABC', 'DEF'), predetermined.colours = c()) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c(), predetermined.colours = c('red', 'green')) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c('ABC','DEF'), predetermined.colours = c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(ABC = 'red',DEF = 'green'), value.order = c('ABC','DEF')))) | ||
| result <- get.colours.in.order(c('ABC','DEF'), predetermined.colours = c('red')) | ||
| expect_equal(names(result), c('colours', 'value.order')) | ||
| expect_equal(names(result$colours), c('ABC', 'DEF')) | ||
| expect_true(result$colours['ABC'] == 'red') | ||
| expect_true(!is.na(result$colours['DEF']) && nzchar(result$colours['DEF'])) | ||
| expect_equal(result$value.order, c('ABC','DEF')) | ||
|
|
||
| result <- get.colours.in.order(c('ABC','DEF'), predetermined.colours = c(NULL,'red')) | ||
| expect_equal(names(result), c('colours', 'value.order')) | ||
| expect_equal(names(result$colours), c('ABC','DEF')) | ||
| expect_true(result$colours['ABC'] == 'red') | ||
| expect_true(!is.na(result$colours['DEF']) && nzchar(result$colours['DEF'])) | ||
| expect_equal(result$value.order, c('ABC','DEF')) | ||
|
|
||
| result <- get.colours.in.order(c('ABC','DEF'), predetermined.colours = c('red',NULL)) | ||
| expect_equal(names(result), c('colours', 'value.order')) | ||
| expect_equal(names(result$colours), c('ABC','DEF')) | ||
| expect_true(result$colours['ABC'] == 'red') | ||
| expect_true(!is.na(result$colours['DEF']) && nzchar(result$colours['DEF'])) | ||
| expect_equal(result$value.order, c('ABC','DEF')) | ||
|
|
||
| result <- get.colours.in.order(c('ABC'), predetermined.colours = c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(ABC = 'red'), value.order = c('ABC')))) | ||
| result <- get.colours.in.order(c(NULL,'ABC'), predetermined.colours = c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(ABC = 'red'), value.order = c('ABC')))) | ||
| result <- get.colours.in.order(c('ABC',NULL), predetermined.colours = c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(ABC = 'red'), value.order = c('ABC')))) | ||
| }); | ||
|
|
||
| test_that( | ||
| 'get.colours.in.order returns expected vectors when order is specified', { | ||
| # get.colours.in.order with order specified | ||
| result <- get.colours.in.order(NULL, c('DEF','ABC'), NULL) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c('ABC', 'DEF'), c('DEF','ABC'), NULL) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(NULL, predetermined.colours = c('red','green')) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = NULL))) | ||
| result <- get.colours.in.order(c(), c('DEF', 'ABC'), c()) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c(), c('DEF','ABC'), NULL) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(NULL, c('DEF', 'ABC'), c()) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c('ABC', 'DEF'), c('DEF', 'ABC'), c()) | ||
| expect_true(setequal(result, list(predetermined.colours = NULL, value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c(), c('DEF','ABC'), c('red', 'green')) | ||
| expect_true(setequal(result, list(predetermined.colours = c(DEF = 'red',ABC = 'green'), value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c('ABC','DEF'), c('DEF','ABC'), c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(DEF = 'red',ABC = 'green'), value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c('ABC','DEF'), c('DEF','ABC'), c('red')) | ||
| expect_equal(names(result), c('colours', 'value.order')) | ||
| expect_equal(names(result$colours), c('DEF', 'ABC')) | ||
| expect_true(result$colours['DEF'] == 'red') | ||
| expect_true(!is.na(result$colours['ABC']) && nzchar(result$colours['ABC'])) | ||
| expect_equal(result$value.order, c('DEF','ABC')) | ||
|
|
||
| result <- get.colours.in.order(c('ABC','DEF'), c('DEF','ABC'), c(NULL,'red')) | ||
| expect_equal(names(result), c('colours', 'value.order')) | ||
| expect_equal(names(result$colours), c('DEF','ABC')) | ||
| expect_true(result$colours['DEF'] == 'red') | ||
| expect_true(!is.na(result$colours['ABC']) && nzchar(result$colours['ABC'])) | ||
| expect_equal(result$value.order, c('DEF','ABC')) | ||
|
|
||
| result <- get.colours.in.order(c('ABC','DEF'), c('DEF','ABC'), c('red',NULL)) | ||
| expect_equal(names(result), c('colours', 'value.order')) | ||
| expect_equal(names(result$colours), c('DEF','ABC')) | ||
| expect_true(result$colours['DEF'] == 'red') | ||
| expect_true(!is.na(result$colours['ABC']) && nzchar(result$colours['ABC'])) | ||
| expect_equal(result$value.order, c('DEF','ABC')) | ||
|
|
||
| result <- get.colours.in.order(c('ABC'), c('DEF','ABC'), c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(DEF = 'red',ABC = 'green'), value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c(NULL,'ABC'), c('DEF','ABC'), c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(DEF = 'red',ABC = 'green'), value.order = c('DEF','ABC')))) | ||
| result <- get.colours.in.order(c('ABC',NULL), c('DEF','ABC'), c('red','green')) | ||
| expect_true(setequal(result,list(predetermined.colours = c(DEF = 'red',ABC = 'green'), value.order = c('DEF','ABC')))) | ||
| }); |
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.
@dan-knight I think I've brought up using Roxugen in the past, do we want to use this for the rest of the documentation as well? I think if we start using it, we should standardize it.
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.
Yeah, we're not using Roxygen in this package. It doesn't make sense to sneak it into this change.
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.
From our conversation, this came from running
devtools::document()so I could use these functions locally. I don't intend to introduce Roxygen, so this can be removed.