From f87c03984fc54f938232f4ae5e8ca53e701963a8 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 11:43:33 -0700 Subject: [PATCH 01/29] Utility function to convert radians to degrees --- R/utility.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/utility.R b/R/utility.R index e780345..ffd9d59 100644 --- a/R/utility.R +++ b/R/utility.R @@ -34,6 +34,10 @@ degrees.to.radians <- function(degrees) { return(degrees * pi / 180); } +radians.to.degrees <- function(radians) { + return(radians * 180 / pi); +} + get.encoded.distance <- function(points) { if (!is.data.frame(points)) { stop(paste( From 3400b7e4eb54dac5ba5675ee1d76b18eff6926bd Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 11:44:05 -0700 Subject: [PATCH 02/29] Fuzz testing function to randomize tree plotting direction --- R/fuzz.R | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 R/fuzz.R diff --git a/R/fuzz.R b/R/fuzz.R new file mode 100644 index 0000000..c8f58c4 --- /dev/null +++ b/R/fuzz.R @@ -0,0 +1,29 @@ +randomize.tree <- function( + tree.df, + randomize.angles = TRUE, + randomize.plotting.direction = TRUE, + plotting.direction = NULL, + ... + ) { + node.ids <- c(get.root.node(tree.df)); + + spread.randomization.sd <- 0.5; + angle.randomization.sd <- 30; + + if (randomize.plotting.direction) { + if (is.null(plotting.direction)) { + plotting.direction <- sample(c('down', 'right', 'left', 'up'), size = 1); + } + plotting.direction <- radians.to.degrees( + prep.plotting.direction(plotting.direction, radians = FALSE) + ); + plotting.direction <- plotting.direction + rnorm(sd = angle.randomization.sd, n = 1); + } + + result <- SRCGrob( + tree.df, + plotting.direction = plotting.direction, + ... + ); + return(result); + } From f2ddc991f3c6a3c4712c93bac1aef0def6fe5d68 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 11:50:03 -0700 Subject: [PATCH 03/29] Randomize tree spread in fuzz testing --- R/fuzz.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/R/fuzz.R b/R/fuzz.R index c8f58c4..1bd1ff3 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -8,8 +8,21 @@ randomize.tree <- function( node.ids <- c(get.root.node(tree.df)); spread.randomization.sd <- 0.5; - angle.randomization.sd <- 30; + if (randomize.angles) { + default.spread <- 1; + if (is.null(tree.df$spread)) { + tree.df$spread <- default.spread; + } else { + tree.df[is.na(tree.df$spread), 'spread'] <- 1; + } + tree.df$spread <- tree.df$spread + rnorm( + mean = 0, + sd = spread.randomization.sd, + n = nrow(tree.df) + ); + } + angle.randomization.sd <- 30; if (randomize.plotting.direction) { if (is.null(plotting.direction)) { plotting.direction <- sample(c('down', 'right', 'left', 'up'), size = 1); From 13fd24eebb860bed2166985483cb853fb2acd83a Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 13:31:01 -0700 Subject: [PATCH 04/29] Utility function to generate random color --- R/utility.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/utility.R b/R/utility.R index ffd9d59..9d61f31 100644 --- a/R/utility.R +++ b/R/utility.R @@ -66,3 +66,7 @@ get.encoded.distance <- function(points) { return(encoded.distances); } + +generate.random.color <- function() { + rgb(runif(1), runif(1), runif(1)); + } From 80f58d3426d745d5fb1f918ab05724e9c72a9ecf Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 14:02:25 -0700 Subject: [PATCH 05/29] Bugs in spread randomization --- R/fuzz.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/fuzz.R b/R/fuzz.R index 1bd1ff3..7b1e681 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -10,7 +10,7 @@ randomize.tree <- function( spread.randomization.sd <- 0.5; if (randomize.angles) { default.spread <- 1; - if (is.null(tree.df$spread)) { + if (!('spread' %in% colnames(tree.df))) { tree.df$spread <- default.spread; } else { tree.df[is.na(tree.df$spread), 'spread'] <- 1; @@ -20,6 +20,7 @@ randomize.tree <- function( sd = spread.randomization.sd, n = nrow(tree.df) ); + tree.df[tree.df$spread < 0, 'spread'] <- 0; } angle.randomization.sd <- 30; From e803f08f3d6f2be183ccf4cb08045f51a034cbce Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 14:02:32 -0700 Subject: [PATCH 06/29] Randomize node color --- R/fuzz.R | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/R/fuzz.R b/R/fuzz.R index 7b1e681..a41a485 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -1,6 +1,7 @@ randomize.tree <- function( tree.df, randomize.angles = TRUE, + randomize.node.color = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -34,6 +35,29 @@ randomize.tree <- function( plotting.direction <- plotting.direction + rnorm(sd = angle.randomization.sd, n = 1); } + if (randomize.node.color) { + node.color.randomization.prob <- 0.5; + node.color.scheme <- if (runif(1) <= node.color.randomization.prob) { + generate.random.color(); + } else { + NA; + } + + if (!('node.col' %in% colnames(tree.df))) { + tree.df$node.col <- node.color.scheme; + } else { + tree.df[is.na(tree.df$node.col), 'node.col'] <- node.color.scheme; + } + override.node.col.i <- sapply( + 1:nrow(tree.df), + function(i) runif(1) <= node.color.randomization.prob + ); + tree.df[override.node.col.i, 'node.col'] <- sapply( + 1:sum(override.node.col.i), + function(i) generate.random.color() + ); + } + result <- SRCGrob( tree.df, plotting.direction = plotting.direction, From c63a589e18b212708826cbf363642467294e857c Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Tue, 6 May 2025 14:05:22 -0700 Subject: [PATCH 07/29] Randomize node border color --- R/fuzz.R | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/R/fuzz.R b/R/fuzz.R index a41a485..6d4b81f 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -2,6 +2,7 @@ randomize.tree <- function( tree.df, randomize.angles = TRUE, randomize.node.color = TRUE, + randomize.node.border.color = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -58,6 +59,29 @@ randomize.tree <- function( ); } + if (randomize.node.border.color) { + node.border.color.randomization.prob <- 0.3; + node.border.color.scheme <- if (runif(1) <= node.border.color.randomization.prob) { + generate.random.color(); + } else { + NA; + } + + if (!('border.col' %in% colnames(tree.df))) { + tree.df$border.col <- node.border.color.scheme; + } else { + tree.df[is.na(tree.df$border.col), 'border.col'] <- node.color.scheme; + } + override.node.border.col.i <- sapply( + 1:nrow(tree.df), + function(i) runif(1) <= node.border.color.randomization.prob + ); + tree.df[override.node.border.col.i, 'border.col'] <- sapply( + 1:sum(override.node.border.col.i), + function(i) generate.random.color() + ); + } + result <- SRCGrob( tree.df, plotting.direction = plotting.direction, From 542febe546fce6817dfc618453bd24ee53378cc0 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 9 May 2025 20:47:41 -0700 Subject: [PATCH 08/29] Randomize node border width --- R/fuzz.R | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 6d4b81f..e794b40 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -2,7 +2,8 @@ randomize.tree <- function( tree.df, randomize.angles = TRUE, randomize.node.color = TRUE, - randomize.node.border.color = TRUE, + randomize.border.color = TRUE, + randomize.border.width = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -59,29 +60,45 @@ randomize.tree <- function( ); } - if (randomize.node.border.color) { - node.border.color.randomization.prob <- 0.3; - node.border.color.scheme <- if (runif(1) <= node.border.color.randomization.prob) { + if (randomize.border.color) { + border.color.randomization.prob <- 0.3; + border.color.scheme <- if (runif(1) <= border.color.randomization.prob) { generate.random.color(); } else { NA; } if (!('border.col' %in% colnames(tree.df))) { - tree.df$border.col <- node.border.color.scheme; + tree.df$border.col <- border.color.scheme; } else { tree.df[is.na(tree.df$border.col), 'border.col'] <- node.color.scheme; } - override.node.border.col.i <- sapply( + override.border.col.i <- sapply( 1:nrow(tree.df), - function(i) runif(1) <= node.border.color.randomization.prob + function(i) runif(1) <= border.color.randomization.prob ); - tree.df[override.node.border.col.i, 'border.col'] <- sapply( - 1:sum(override.node.border.col.i), + tree.df[override.border.col.i, 'border.col'] <- sapply( + 1:sum(override.border.col.i), function(i) generate.random.color() ); } + if (randomize.border.width) { + border.width.randomization.prob <- 0.3; + default.border.width <- 1; + if (!('border.width' %in% colnames(tree.df))) { + tree.df$border.width <- default.border.width; + } else { + tree.df[is.na(tree.df$border.width), 'border.width'] <- default.border.width; + } + tree.df[, 'border.width'] <- tree.df$border.width + rnorm( + mean = 0, + sd = 1, + n = nrow(tree.df) + ); + tree.df[tree.df$border.width <= 0, 'border.width'] <- 0; + } + result <- SRCGrob( tree.df, plotting.direction = plotting.direction, From 2f90d41b6233d09d1e21ac1a105985a18f547182 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 9 May 2025 21:02:58 -0700 Subject: [PATCH 09/29] Randomize node border line type --- R/fuzz.R | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index e794b40..fe14254 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -4,6 +4,7 @@ randomize.tree <- function( randomize.node.color = TRUE, randomize.border.color = TRUE, randomize.border.width = TRUE, + randomize.border.type = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -84,8 +85,9 @@ randomize.tree <- function( } if (randomize.border.width) { - border.width.randomization.prob <- 0.3; + border.width.randomization.sd <- 1; default.border.width <- 1; + if (!('border.width' %in% colnames(tree.df))) { tree.df$border.width <- default.border.width; } else { @@ -93,12 +95,32 @@ randomize.tree <- function( } tree.df[, 'border.width'] <- tree.df$border.width + rnorm( mean = 0, - sd = 1, + sd = border.width.randomization.sd, n = nrow(tree.df) ); tree.df[tree.df$border.width <= 0, 'border.width'] <- 0; } + if (randomize.border.type) { + border.type.randomization.prob <- 0.3; + default.border.type <- 'solid'; + + if (!('border.type' %in% colnames(tree.df))) { + tree.df$border.type <- default.border.type; + } else { + tree.df[is.na(tree.df$border.type), 'border.type'] <- default.border.type; + } + override.border.type.i <- sapply( + 1:nrow(tree.df), + function(i) runif(1) <= border.type.randomization.prob + ); + tree.df[override.border.type.i, 'border.type'] <- sample( + c('solid', 'dashed', 'dotted'), + size = sum(override.border.type.i), + replace = TRUE + ); + } + result <- SRCGrob( tree.df, plotting.direction = plotting.direction, From 44fb328e89db15f0c361926181354a54b38f796e Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 9 May 2025 21:21:22 -0700 Subject: [PATCH 10/29] Randomize edge colors --- R/fuzz.R | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/R/fuzz.R b/R/fuzz.R index fe14254..b778aeb 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -5,6 +5,7 @@ randomize.tree <- function( randomize.border.color = TRUE, randomize.border.width = TRUE, randomize.border.type = TRUE, + randomize.edge.cols = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -121,6 +122,34 @@ randomize.tree <- function( ); } + edge.names <- sort(get.branch.names(tree.df)); + if (length(edge.names) < 1) { + edge.names <- 1; + } + for (edge.name in edge.names) { + if (randomize.edge.cols) { + edge.color.scheme.randomization.prob <- 0.5; + edge.color.randomization.prob <- 0.3; + edge.color.scheme <- if (runif(1) <= edge.color.scheme.randomization.prob) { + generate.random.color(); + } else { + NA; + } + + edge.col.column.name <- paste('edge.col', edge.name, sep = '.'); + if (!(edge.col.column.name %in% colnames(tree.df))) { + tree.df[, edge.col.column.name] <- edge.color.scheme; + } else { + tree.df[is.na(tree.df$border.col), edge.col.column.name] <- edge.color.scheme; + } + override.edge.col.i <- runif(n = nrow(tree.df), max = 1) <= edge.color.randomization.prob; + tree.df[override.edge.col.i, edge.col.column.name] <- sapply( + 1:sum(override.edge.col.i), + function(i) generate.random.color() + ); + } + } + result <- SRCGrob( tree.df, plotting.direction = plotting.direction, From eca98e10c32fc3a65791313046365362e9d082f5 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 9 May 2025 21:29:54 -0700 Subject: [PATCH 11/29] Randomize edge widths --- R/fuzz.R | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/R/fuzz.R b/R/fuzz.R index b778aeb..73c702e 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -6,6 +6,7 @@ randomize.tree <- function( randomize.border.width = TRUE, randomize.border.type = TRUE, randomize.edge.cols = TRUE, + randomize.edge.width = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -140,7 +141,7 @@ randomize.tree <- function( if (!(edge.col.column.name %in% colnames(tree.df))) { tree.df[, edge.col.column.name] <- edge.color.scheme; } else { - tree.df[is.na(tree.df$border.col), edge.col.column.name] <- edge.color.scheme; + tree.df[is.na(tree.df[, edge.col.column.name]), edge.col.column.name] <- edge.color.scheme; } override.edge.col.i <- runif(n = nrow(tree.df), max = 1) <= edge.color.randomization.prob; tree.df[override.edge.col.i, edge.col.column.name] <- sapply( @@ -148,6 +149,29 @@ randomize.tree <- function( function(i) generate.random.color() ); } + + if (randomize.edge.width) { + base.edge.width.randomization.prob <- 0.5; + edge.width.randomization.prob <- 0.3; + default.edge.width <- if (runif(1) <= base.edge.width.randomization.prob) { + max(0, rnorm(1, mean = 3)); + } else { + 3; + } + + edge.width.column.name <- paste('edge.width', edge.name, sep = '.'); + if (!(edge.width.column.name %in% colnames(tree.df))) { + tree.df[, edge.width.column.name] <- default.edge.width; + } else { + tree.df[is.na(tree.df[, edge.width.column.name]), edge.col.column.name] <- default.edge.width; + } + override.edge.width.i <- runif(n = nrow(tree.df), max = 1) <= edge.width.randomization.prob; + tree.df[, edge.width.column.name] <- tree.df[, edge.width.column.name] + rnorm(nrow(tree.df)); + tree.df[, edge.width.column.name] <- sapply( + tree.df[, edge.width.column.name], + function(x) max(0, x) + ); + } } result <- SRCGrob( From e26463b3ed1377d27966d28b9bc3a6eb2eeece0d Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 9 May 2025 21:30:23 -0700 Subject: [PATCH 12/29] Parameter name consistency --- R/fuzz.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 73c702e..7feda70 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -5,7 +5,7 @@ randomize.tree <- function( randomize.border.color = TRUE, randomize.border.width = TRUE, randomize.border.type = TRUE, - randomize.edge.cols = TRUE, + randomize.edge.col = TRUE, randomize.edge.width = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, @@ -128,7 +128,7 @@ randomize.tree <- function( edge.names <- 1; } for (edge.name in edge.names) { - if (randomize.edge.cols) { + if (randomize.edge.col) { edge.color.scheme.randomization.prob <- 0.5; edge.color.randomization.prob <- 0.3; edge.color.scheme <- if (runif(1) <= edge.color.scheme.randomization.prob) { From 9850e286d350075a4fbfb66759cbbf92ca60015c Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 9 May 2025 21:59:36 -0700 Subject: [PATCH 13/29] Randomize edge line types --- R/fuzz.R | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 7feda70..80ac22c 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -7,12 +7,16 @@ randomize.tree <- function( randomize.border.type = TRUE, randomize.edge.col = TRUE, randomize.edge.width = TRUE, + randomize.edge.type = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... ) { node.ids <- c(get.root.node(tree.df)); + default.line.type <- 'solid'; + line.types <- c(default.line.type, 'dotted', 'dashed'); + spread.randomization.sd <- 0.5; if (randomize.angles) { default.spread <- 1; @@ -104,8 +108,13 @@ randomize.tree <- function( } if (randomize.border.type) { + base.border.type.randomization.prob <- 0.5; border.type.randomization.prob <- 0.3; - default.border.type <- 'solid'; + default.border.type <- if (runif(1) <= base.border.type.randomization.prob) { + sample(line.types, size = 1); + } else { + default.line.type; + } if (!('border.type' %in% colnames(tree.df))) { tree.df$border.type <- default.border.type; @@ -117,7 +126,7 @@ randomize.tree <- function( function(i) runif(1) <= border.type.randomization.prob ); tree.df[override.border.type.i, 'border.type'] <- sample( - c('solid', 'dashed', 'dotted'), + line.types, size = sum(override.border.type.i), replace = TRUE ); @@ -172,6 +181,29 @@ randomize.tree <- function( function(x) max(0, x) ); } + + if (randomize.edge.type) { + base.edge.type.randomization.prob <- 0.5; + edge.type.randomization.prob <- 0.3; + default.edge.type <- if (runif(1) <= base.edge.type.randomization.prob) { + sample(line.types, size = 1); + } else { + default.line.type; + } + + edge.type.column.name <- paste('edge.type', edge.name, sep = '.'); + if (!(edge.type.column.name %in% colnames(tree.df))) { + tree.df[, edge.type.column.name] <- default.edge.type; + } else { + tree.df[is.na(tree.df[, edge.type.column.name]), edge.col.column.name] <- default.edge.type; + } + override.edge.type.i <- runif(n = nrow(tree.df), max = 1) <= edge.type.randomization.prob; + tree.df[override.edge.type.i, edge.type.column.name] <- sample( + line.types, + size = sum(override.edge.type.i), + replace = TRUE + ); + } } result <- SRCGrob( From 9cf17920c00b802ec8969c9878db34cef883823f Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Wed, 14 May 2025 16:35:06 -0700 Subject: [PATCH 14/29] Randomize edge lengths --- R/fuzz.R | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 80ac22c..37a3c2a 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -8,6 +8,7 @@ randomize.tree <- function( randomize.edge.col = TRUE, randomize.edge.width = TRUE, randomize.edge.type = TRUE, + randomize.edge.length = TRUE, randomize.plotting.direction = TRUE, plotting.direction = NULL, ... @@ -121,10 +122,7 @@ randomize.tree <- function( } else { tree.df[is.na(tree.df$border.type), 'border.type'] <- default.border.type; } - override.border.type.i <- sapply( - 1:nrow(tree.df), - function(i) runif(1) <= border.type.randomization.prob - ); + override.border.type.i <- runif(nrow(tree.df)) <= border.type.randomization.prob; tree.df[override.border.type.i, 'border.type'] <- sample( line.types, size = sum(override.border.type.i), @@ -204,6 +202,22 @@ randomize.tree <- function( replace = TRUE ); } + + if (randomize.edge.length) { + edge.length.column.name <- paste('length', edge.name, sep = '.'); + base.edge.length <- 10 ** runif(n = 1, min = 0, max = 6); + if (!(edge.length.column.name %in% colnames(tree.df))) { + tree.df[, edge.length.column.name] <- base.edge.length; + } else { + tree.df[is.na(tree.df[, edge.length.column.name]), edge.length.column.name] <- base.edge.length; + } + edge.length.randomization.sd <- median(tree.df[, edge.length.column.name]) * 0.2; + tree.df[, edge.length.column.name] <- tree.df[, edge.length.column.name] + rnorm( + sd = edge.length.randomization.sd, + n = nrow(tree.df) + ); + tree.df[tree.df[, edge.length.column.name] < 0, edge.length.column.name] + } } result <- SRCGrob( From 7c4bab435da155e33d44837c8130a2b1d54e1aac Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Wed, 14 May 2025 17:18:31 -0700 Subject: [PATCH 15/29] Utility function to parse fuzz test randomization input --- R/fuzz.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/R/fuzz.R b/R/fuzz.R index 37a3c2a..3a07414 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -227,3 +227,26 @@ randomize.tree <- function( ); return(result); } + +check.randomization.value <- function( + randomization, + default.value, + randomization.name = NULL + ) { + if (is.null(randomization.name)) { + randomization.name <- 'Randomization value'; + } + if (length(randomization) != 1) { + stop(paste(randomization.name, 'must be length 1.')); + } + + randomize.result <- FALSE; + if (is.numeric(randomization)) { + randomize.result <- TRUE; + } else if (is.logical(randomization)) { + randomize.result <- randomization; + } else { + stop(paste(randomization.name, 'must be numeric or TRUE/FALSE.')); + } + return(randomize.result); + } From fcf1c6396be065c975fa21fabe29b752646c6e9a Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Wed, 14 May 2025 17:19:01 -0700 Subject: [PATCH 16/29] Specify angle randomization spread standard deviation --- R/fuzz.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 3a07414..275df32 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -18,8 +18,15 @@ randomize.tree <- function( default.line.type <- 'solid'; line.types <- c(default.line.type, 'dotted', 'dashed'); - spread.randomization.sd <- 0.5; - if (randomize.angles) { + if (check.randomization.value(randomize.angles)) { + spread.randomization.sd <- if (is.numeric(randomize.angles)) { + if (randomize.angles <= 0) { + stop('"randomize.angles" standard deviation value must be positive.'); + } + randomize.angles; + } else { + 0.5; + } default.spread <- 1; if (!('spread' %in% colnames(tree.df))) { tree.df$spread <- default.spread; From 60669c06630636e84bbc9e45bb49f151fc3fe747 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Wed, 14 May 2025 17:53:06 -0700 Subject: [PATCH 17/29] Specify randomized plotting direction standard deviation --- R/fuzz.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 275df32..3c60019 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -41,14 +41,21 @@ randomize.tree <- function( tree.df[tree.df$spread < 0, 'spread'] <- 0; } - angle.randomization.sd <- 30; - if (randomize.plotting.direction) { + if (check.randomization.value(randomize.plotting.direction)) { if (is.null(plotting.direction)) { plotting.direction <- sample(c('down', 'right', 'left', 'up'), size = 1); } plotting.direction <- radians.to.degrees( prep.plotting.direction(plotting.direction, radians = FALSE) ); + angle.randomization.sd <- if (is.numeric(randomize.plotting.direction)) { + if (randomize.plotting.direction <= 0) { + stop('"randomize.plotting.direction" standard deviation value must be positive.'); + } + randomize.plotting.direction; + } else { + 30 + }; plotting.direction <- plotting.direction + rnorm(sd = angle.randomization.sd, n = 1); } From 878744caa155a11a0c100957e9cfd9fd24631b19 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Thu, 15 May 2025 19:28:41 -0700 Subject: [PATCH 18/29] Specify randomized node color probability --- R/fuzz.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 3c60019..451885b 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -59,8 +59,15 @@ randomize.tree <- function( plotting.direction <- plotting.direction + rnorm(sd = angle.randomization.sd, n = 1); } - if (randomize.node.color) { - node.color.randomization.prob <- 0.5; + if (check.randomization.value(randomize.node.color)) { + node.color.randomization.prob <- if (is.numeric(randomize.node.color)) { + if (randomize.node.color < 0 || randomize.node.color > 1) { + stop('"randomize.node.color" probability must be between 0 and 1.') + } + randomize.node.color; + } else { + 0.5; + } node.color.scheme <- if (runif(1) <= node.color.randomization.prob) { generate.random.color(); } else { From 4b00fd6f1353429340320fe47445f6dc909e17f3 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Thu, 15 May 2025 19:33:23 -0700 Subject: [PATCH 19/29] Specify randomized border color probability --- R/fuzz.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 451885b..37be229 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -89,8 +89,15 @@ randomize.tree <- function( ); } - if (randomize.border.color) { - border.color.randomization.prob <- 0.3; + if (check.randomization.value(randomize.border.color)) { + border.color.randomization.prob <- if (is.numeric(randomize.border.color)) { + if (randomize.border.color < 0 || randomize.border.color > 1) { + stop('"randomize.border.color" probability must be between 0 and 1.') + } + randomize.border.color; + } else { + 0.3; + } border.color.scheme <- if (runif(1) <= border.color.randomization.prob) { generate.random.color(); } else { From 59658a49d134d95b75a0361cd7aad92951ccab02 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Thu, 15 May 2025 19:44:21 -0700 Subject: [PATCH 20/29] Specify randomized border width standard deviation --- R/fuzz.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 37be229..36b5e3a 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -119,8 +119,15 @@ randomize.tree <- function( ); } - if (randomize.border.width) { - border.width.randomization.sd <- 1; + if (check.randomization.value(randomize.border.width)) { + border.width.randomization.sd <- if (is.numeric(randomize.border.width)) { + if (randomize.border.width <= 0) { + stop('"randomize.border.width" standard deviation value must be positive.'); + } + randomize.border.width; + } else { + 1 + }; default.border.width <- 1; if (!('border.width' %in% colnames(tree.df))) { From b0a4e39c4ab055105f3d2ce9271b8dc3e3d3f0ce Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 16 May 2025 08:39:08 -0700 Subject: [PATCH 21/29] Specify randomized border type probability --- R/fuzz.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 36b5e3a..029a0e4 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -143,13 +143,16 @@ randomize.tree <- function( tree.df[tree.df$border.width <= 0, 'border.width'] <- 0; } - if (randomize.border.type) { - base.border.type.randomization.prob <- 0.5; - border.type.randomization.prob <- 0.3; - default.border.type <- if (runif(1) <= base.border.type.randomization.prob) { - sample(line.types, size = 1); + if (check.randomization.value(randomize.border.type)) { + default.border.type <- sample(line.types, size = 1); + + border.type.randomization.prob <- if (is.numeric(randomize.border.type)) { + if (randomize.border.type < 0 || randomize.border.type > 1) { + stop('"randomize.border.type" probability must be between 0 and 1.') + } + randomize.border.type; } else { - default.line.type; + 0.3; } if (!('border.type' %in% colnames(tree.df))) { From e730626e9ed425ceca12e943cf2a0da716628a8b Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 16 May 2025 08:44:14 -0700 Subject: [PATCH 22/29] Specify randomized edge color probability --- R/fuzz.R | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 029a0e4..d748836 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -172,15 +172,22 @@ randomize.tree <- function( if (length(edge.names) < 1) { edge.names <- 1; } + + edge.color.randomization.prob <- 0; + if (check.randomization.value(randomize.edge.col)) { + edge.color.randomization.prob <- if (is.numeric(randomize.edge.col)) { + if (randomize.edge.col < 0 || randomize.edge.col > 1) { + stop('"randomize.edge.col" probability must be between 0 and 1.') + } + randomize.edge.col; + } else { + 0.3; + } + } + for (edge.name in edge.names) { - if (randomize.edge.col) { - edge.color.scheme.randomization.prob <- 0.5; - edge.color.randomization.prob <- 0.3; - edge.color.scheme <- if (runif(1) <= edge.color.scheme.randomization.prob) { - generate.random.color(); - } else { - NA; - } + if (check.randomization.value(randomize.edge.col)) { + edge.color.scheme <- generate.random.color(); edge.col.column.name <- paste('edge.col', edge.name, sep = '.'); if (!(edge.col.column.name %in% colnames(tree.df))) { From 7d1e72901462a28cd36ea6b10361c64d65c5c0df Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 16 May 2025 09:02:53 -0700 Subject: [PATCH 23/29] Specify randomized edge width standard deviation --- R/fuzz.R | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index d748836..3350635 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -185,6 +185,15 @@ randomize.tree <- function( } } + edge.width.randomization.sd <- if (is.numeric(randomize.edge.width)) { + if (randomize.edge.width <= 0) { + stop('"randomize.edge.width" standard deviation value must be positive.'); + } + randomize.edge.width; + } else { + 1 + }; + for (edge.name in edge.names) { if (check.randomization.value(randomize.edge.col)) { edge.color.scheme <- generate.random.color(); @@ -202,9 +211,8 @@ randomize.tree <- function( ); } - if (randomize.edge.width) { + if (check.randomization.value(randomize.edge.width)) { base.edge.width.randomization.prob <- 0.5; - edge.width.randomization.prob <- 0.3; default.edge.width <- if (runif(1) <= base.edge.width.randomization.prob) { max(0, rnorm(1, mean = 3)); } else { @@ -217,8 +225,10 @@ randomize.tree <- function( } else { tree.df[is.na(tree.df[, edge.width.column.name]), edge.col.column.name] <- default.edge.width; } - override.edge.width.i <- runif(n = nrow(tree.df), max = 1) <= edge.width.randomization.prob; - tree.df[, edge.width.column.name] <- tree.df[, edge.width.column.name] + rnorm(nrow(tree.df)); + tree.df[, edge.width.column.name] <- tree.df[, edge.width.column.name] + rnorm( + sd = edge.width.randomization.sd, + n = nrow(tree.df) + ); tree.df[, edge.width.column.name] <- sapply( tree.df[, edge.width.column.name], function(x) max(0, x) From ae070c450103c3a247a71f46cb78598dadb2acb3 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 16 May 2025 09:10:20 -0700 Subject: [PATCH 24/29] Specify randomized edge type probability --- R/fuzz.R | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 3350635..76cc79f 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -194,6 +194,18 @@ randomize.tree <- function( 1 }; + edge.type.randomization.prob <- 0; + if (check.randomization.value(randomize.edge.type)) { + edge.type.randomization.prob <- if (is.numeric(randomize.edge.type)) { + if (randomize.edge.type < 0 || randomize.edge.type > 1) { + stop('"randomize.edge.type" probability must be between 0 and 1.') + } + randomize.edge.type; + } else { + 0.3; + } + } + for (edge.name in edge.names) { if (check.randomization.value(randomize.edge.col)) { edge.color.scheme <- generate.random.color(); @@ -235,14 +247,8 @@ randomize.tree <- function( ); } - if (randomize.edge.type) { - base.edge.type.randomization.prob <- 0.5; - edge.type.randomization.prob <- 0.3; - default.edge.type <- if (runif(1) <= base.edge.type.randomization.prob) { - sample(line.types, size = 1); - } else { - default.line.type; - } + if (check.randomization.value(randomize.edge.type)) { + default.edge.type <- sample(line.types, size = 1); edge.type.column.name <- paste('edge.type', edge.name, sep = '.'); if (!(edge.type.column.name %in% colnames(tree.df))) { From be6b41c0b330ec52a7a01b5ddb39cdbe0094f84b Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 16 May 2025 09:13:41 -0700 Subject: [PATCH 25/29] Specify edge length randomization proportion --- R/fuzz.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 76cc79f..5326496 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -264,15 +264,25 @@ randomize.tree <- function( ); } - if (randomize.edge.length) { + if (check.randomization.value(randomize.edge.length)) { edge.length.column.name <- paste('length', edge.name, sep = '.'); base.edge.length <- 10 ** runif(n = 1, min = 0, max = 6); + + edge.length.randomization.proportion <- if (is.numeric(randomize.edge.length)) { + if (randomize.edge.length <= 0) { + stop('"randomize.edge.length" proportion must be positive.'); + } + randomize.edge.length; + } else { + 0.2; + } + if (!(edge.length.column.name %in% colnames(tree.df))) { tree.df[, edge.length.column.name] <- base.edge.length; } else { tree.df[is.na(tree.df[, edge.length.column.name]), edge.length.column.name] <- base.edge.length; } - edge.length.randomization.sd <- median(tree.df[, edge.length.column.name]) * 0.2; + edge.length.randomization.sd <- median(tree.df[, edge.length.column.name]) * edge.length.randomization.proportion; tree.df[, edge.length.column.name] <- tree.df[, edge.length.column.name] + rnorm( sd = edge.length.randomization.sd, n = nrow(tree.df) From fcbbc4b9726d91a14b3ac9e06d6ca5904c8f9d5c Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Fri, 16 May 2025 19:19:29 -0700 Subject: [PATCH 26/29] Test fuzz randomization parameter types --- R/fuzz.R | 47 +++++++------ tests/testthat/test-fuzz.R | 140 +++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 tests/testthat/test-fuzz.R diff --git a/R/fuzz.R b/R/fuzz.R index 5326496..293d5da 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -18,7 +18,7 @@ randomize.tree <- function( default.line.type <- 'solid'; line.types <- c(default.line.type, 'dotted', 'dashed'); - if (check.randomization.value(randomize.angles)) { + if (check.randomization.value(randomize.angles, randomization.name = 'randomize.angles')) { spread.randomization.sd <- if (is.numeric(randomize.angles)) { if (randomize.angles <= 0) { stop('"randomize.angles" standard deviation value must be positive.'); @@ -41,7 +41,7 @@ randomize.tree <- function( tree.df[tree.df$spread < 0, 'spread'] <- 0; } - if (check.randomization.value(randomize.plotting.direction)) { + if (check.randomization.value(randomize.plotting.direction, randomization.name = 'plotting.direction')) { if (is.null(plotting.direction)) { plotting.direction <- sample(c('down', 'right', 'left', 'up'), size = 1); } @@ -54,19 +54,19 @@ randomize.tree <- function( } randomize.plotting.direction; } else { - 30 + 30; }; plotting.direction <- plotting.direction + rnorm(sd = angle.randomization.sd, n = 1); } - if (check.randomization.value(randomize.node.color)) { + if (check.randomization.value(randomize.node.color, randomization.name = 'randomize.node.color')) { node.color.randomization.prob <- if (is.numeric(randomize.node.color)) { if (randomize.node.color < 0 || randomize.node.color > 1) { stop('"randomize.node.color" probability must be between 0 and 1.') } randomize.node.color; } else { - 0.5; + 0.5; } node.color.scheme <- if (runif(1) <= node.color.randomization.prob) { generate.random.color(); @@ -89,11 +89,11 @@ randomize.tree <- function( ); } - if (check.randomization.value(randomize.border.color)) { + if (check.randomization.value(randomize.border.color, randomization.name = 'randomize.border.color')) { border.color.randomization.prob <- if (is.numeric(randomize.border.color)) { if (randomize.border.color < 0 || randomize.border.color > 1) { stop('"randomize.border.color" probability must be between 0 and 1.') - } + } randomize.border.color; } else { 0.3; @@ -119,14 +119,14 @@ randomize.tree <- function( ); } - if (check.randomization.value(randomize.border.width)) { + if (check.randomization.value(randomize.border.width, randomization.name = 'randomize.border.width')) { border.width.randomization.sd <- if (is.numeric(randomize.border.width)) { if (randomize.border.width <= 0) { stop('"randomize.border.width" standard deviation value must be positive.'); - } + } randomize.border.width; } else { - 1 + 1; }; default.border.width <- 1; @@ -143,7 +143,7 @@ randomize.tree <- function( tree.df[tree.df$border.width <= 0, 'border.width'] <- 0; } - if (check.randomization.value(randomize.border.type)) { + if (check.randomization.value(randomize.border.type, randomization.name = 'randomize.border.type')) { default.border.type <- sample(line.types, size = 1); border.type.randomization.prob <- if (is.numeric(randomize.border.type)) { @@ -174,28 +174,30 @@ randomize.tree <- function( } edge.color.randomization.prob <- 0; - if (check.randomization.value(randomize.edge.col)) { + if (check.randomization.value(randomize.edge.col, randomization.name = 'randomize.edge.col')) { edge.color.randomization.prob <- if (is.numeric(randomize.edge.col)) { if (randomize.edge.col < 0 || randomize.edge.col > 1) { stop('"randomize.edge.col" probability must be between 0 and 1.') - } + } randomize.edge.col; } else { 0.3; } } - edge.width.randomization.sd <- if (is.numeric(randomize.edge.width)) { - if (randomize.edge.width <= 0) { - stop('"randomize.edge.width" standard deviation value must be positive.'); + if (check.randomization.value(randomize.edge.width, randomization.name = 'randomize.edge.width')) { + edge.width.randomization.sd <- if (is.numeric(randomize.edge.width)) { + if (randomize.edge.width <= 0) { + stop('"randomize.edge.width" standard deviation value must be positive.'); + } + randomize.edge.width; + } else { + 1; + }; } - randomize.edge.width; - } else { - 1 - }; edge.type.randomization.prob <- 0; - if (check.randomization.value(randomize.edge.type)) { + if (check.randomization.value(randomize.edge.type, randomization.name = 'randomize.edge.type')) { edge.type.randomization.prob <- if (is.numeric(randomize.edge.type)) { if (randomize.edge.type < 0 || randomize.edge.type > 1) { stop('"randomize.edge.type" probability must be between 0 and 1.') @@ -264,7 +266,7 @@ randomize.tree <- function( ); } - if (check.randomization.value(randomize.edge.length)) { + if (check.randomization.value(randomize.edge.length, randomization.name = 'randomize.edge.length')) { edge.length.column.name <- paste('length', edge.name, sep = '.'); base.edge.length <- 10 ** runif(n = 1, min = 0, max = 6); @@ -301,7 +303,6 @@ randomize.tree <- function( check.randomization.value <- function( randomization, - default.value, randomization.name = NULL ) { if (is.null(randomization.name)) { diff --git a/tests/testthat/test-fuzz.R b/tests/testthat/test-fuzz.R new file mode 100644 index 0000000..4be056d --- /dev/null +++ b/tests/testthat/test-fuzz.R @@ -0,0 +1,140 @@ +test_that( + 'randomize.tree errors on invalid angle randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.angle = 'test' + ); + }, + regexp = 'randomize.angle' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid plotting direction randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.plotting.direction = 'test' + ); + }, + regexp = 'plotting.direction' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid node color randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.node.color = 'test' + ); + }, + regexp = 'randomize.node.color' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid border color randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.border.color = 'test' + ); + }, + regexp = 'randomize.border.color' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid border width randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.border.width = 'test' + ); + }, + regexp = 'randomize.border.width' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid border type randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.border.type = 'test' + ); + }, + regexp = 'randomize.border.type' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid edge color randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.col = 'test' + ); + }, + regexp = 'randomize.edge.col' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid edge width randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.width = 'test' + ); + }, + regexp = 'randomize.edge.width' + ); + } + ); + + +test_that( + 'randomize.tree errors on invalid edge length randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.length = 'test' + ); + }, + regexp = 'randomize.edge.length' + ); + } + ); + +test_that( + 'randomize.tree errors on invalid edge type randomization type', { + expect_error( + { + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.type = 'test' + ); + }, + regexp = 'randomize.edge.type' + ); + } + ); From b54e0e28643f515ec88ce4cf3d7abc3c3145bebf Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Wed, 4 Jun 2025 14:07:25 -0700 Subject: [PATCH 27/29] Fix code style --- R/utility.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utility.R b/R/utility.R index 9d61f31..efdac65 100644 --- a/R/utility.R +++ b/R/utility.R @@ -36,7 +36,7 @@ degrees.to.radians <- function(degrees) { radians.to.degrees <- function(radians) { return(radians * 180 / pi); -} + } get.encoded.distance <- function(points) { if (!is.data.frame(points)) { From 8928ca0531344fcba4828bf6a6359ef4daae17c3 Mon Sep 17 00:00:00 2001 From: whelena Date: Tue, 10 Jun 2025 17:52:01 -0700 Subject: [PATCH 28/29] replace SRCGriob with create.phylogenetic.tree --- R/fuzz.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/fuzz.R b/R/fuzz.R index 293d5da..836fa95 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -293,7 +293,7 @@ randomize.tree <- function( } } - result <- SRCGrob( + result <- create.phylogenetic.tree( tree.df, plotting.direction = plotting.direction, ... From 7e4092097eef09bbc30e9f21df636279f0802f21 Mon Sep 17 00:00:00 2001 From: Dan Knight Date: Mon, 16 Jun 2025 14:43:33 -0700 Subject: [PATCH 29/29] Fix code style --- R/fuzz.R | 2 +- tests/testthat/test-fuzz.R | 100 +++++++++++++++---------------------- 2 files changed, 41 insertions(+), 61 deletions(-) diff --git a/R/fuzz.R b/R/fuzz.R index 836fa95..6aedfb2 100644 --- a/R/fuzz.R +++ b/R/fuzz.R @@ -35,7 +35,7 @@ randomize.tree <- function( } tree.df$spread <- tree.df$spread + rnorm( mean = 0, - sd = spread.randomization.sd, + sd = spread.randomization.sd, n = nrow(tree.df) ); tree.df[tree.df$spread < 0, 'spread'] <- 0; diff --git a/tests/testthat/test-fuzz.R b/tests/testthat/test-fuzz.R index 4be056d..a1ddc87 100644 --- a/tests/testthat/test-fuzz.R +++ b/tests/testthat/test-fuzz.R @@ -1,12 +1,10 @@ test_that( 'randomize.tree errors on invalid angle randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.angle = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.angle = 'test' + ), regexp = 'randomize.angle' ); } @@ -15,12 +13,10 @@ test_that( test_that( 'randomize.tree errors on invalid plotting direction randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.plotting.direction = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.plotting.direction = 'test' + ), regexp = 'plotting.direction' ); } @@ -29,12 +25,10 @@ test_that( test_that( 'randomize.tree errors on invalid node color randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.node.color = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.node.color = 'test' + ), regexp = 'randomize.node.color' ); } @@ -43,12 +37,10 @@ test_that( test_that( 'randomize.tree errors on invalid border color randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.border.color = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.border.color = 'test' + ), regexp = 'randomize.border.color' ); } @@ -57,12 +49,10 @@ test_that( test_that( 'randomize.tree errors on invalid border width randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.border.width = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.border.width = 'test' + ), regexp = 'randomize.border.width' ); } @@ -71,12 +61,10 @@ test_that( test_that( 'randomize.tree errors on invalid border type randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.border.type = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.border.type = 'test' + ), regexp = 'randomize.border.type' ); } @@ -85,12 +73,10 @@ test_that( test_that( 'randomize.tree errors on invalid edge color randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.edge.col = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.col = 'test' + ), regexp = 'randomize.edge.col' ); } @@ -99,12 +85,10 @@ test_that( test_that( 'randomize.tree errors on invalid edge width randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.edge.width = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.width = 'test' + ), regexp = 'randomize.edge.width' ); } @@ -114,12 +98,10 @@ test_that( test_that( 'randomize.tree errors on invalid edge length randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.edge.length = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.length = 'test' + ), regexp = 'randomize.edge.length' ); } @@ -128,12 +110,10 @@ test_that( test_that( 'randomize.tree errors on invalid edge type randomization type', { expect_error( - { - randomize.tree( - data.frame(parent = c(NA, 1)), - randomize.edge.type = 'test' - ); - }, + randomize.tree( + data.frame(parent = c(NA, 1)), + randomize.edge.type = 'test' + ), regexp = 'randomize.edge.type' ); }