Skip to content

Commit

Permalink
some future proofing
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Dec 13, 2024
1 parent 4652ffb commit a984594
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 111 deletions.
2 changes: 1 addition & 1 deletion R/scale_dendro.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ scale_x_dendro <- function(clust, ..., expand = waiver(), guide = "axis_dendro",
"x", "xmin", "xmax", "xend", "xintercept",
"xmin_final", "xmax_final", "xlower", "xmiddle", "xupper", "x0"
),
palette = pal_identity(),
palette = seq_len,
scale_name = missing_arg(),
limits = limits,
!!!args,
Expand Down
136 changes: 69 additions & 67 deletions tests/testthat/_snaps/scale_dendro/scale-dendro-cartesian.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 36 additions & 36 deletions tests/testthat/_snaps/scale_dendro/scale-dendro-radial.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testthat/test-gizmo-density.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that("gizmo_density can compute density in various ways", {

values <- mtcars$mpg
target <- density(mtcars$mpg, n = 10)
scale <- scale_colour_continuous(limits = range(values))
scale <- scale_colour_gradient(limits = range(values))
scale$train(values)

guide <- gizmo_density(density = target)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-gizmo-histogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test_that("gizmo_histogram can compute histograms in various ways", {

values <- mtcars$mpg
target <- hist(mtcars$mpg, breaks = 10, plot = FALSE)
scale <- scale_colour_continuous(limits = range(values))
scale <- scale_colour_gradient(limits = range(values))
scale$train(values)
fields <- c("breaks", "counts")

Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-key-group.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

test_that("key_group_split works correctly", {

scale <- scale_colour_discrete()
scale <- scale_colour_hue()
scale$train(c("A:B", "C:D", "E:F"))

# Standard case
Expand All @@ -19,7 +19,7 @@ test_that("key_group_split works correctly", {
)

# Missing label
scale <- scale_colour_discrete()
scale <- scale_colour_hue()
scale$train(c("A", "C:D", "E:F"))

test <- key_group_split(sep = ":")(scale, "colour")
Expand All @@ -29,7 +29,7 @@ test_that("key_group_split works correctly", {
)

# Too many labels
scale <- scale_colour_discrete()
scale <- scale_colour_hue()
scale$train(c("A:B", "C:D", "E:F:G"))

test <- key_group_split(sep = ":")(scale, "colour")
Expand All @@ -39,7 +39,7 @@ test_that("key_group_split works correctly", {
)

# Expression labels
scale <- scale_colour_discrete(labels = expression(A, B, C))
scale <- scale_colour_hue(labels = expression(A, B, C))
scale$train(c("A", "B", "C"))
expect_snapshot(
key_group_split(sep = ":")(scale, "colour"),
Expand All @@ -52,7 +52,7 @@ test_that("key_group_lut works as intended", {
levels <- c("Coffee", "Tea", "Soda", "Water")
groups <- rep(c("Hot drinks", "Cold drinks"), each = 2)

sc <- scale_colour_discrete()
sc <- scale_colour_hue()
sc$train(levels)
sc$train("Car")

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-scale_dendro.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test_that("scale_xy_dendro looks correct", {
yclust <- test_clust(4)

base <- ggplot() +
geom_point(aes(x = "2", y = "3"), shape = NA, na.rm = TRUE) +
scale_x_dendro(xclust) +
scale_y_dendro(yclust) +
theme(
Expand Down

0 comments on commit a984594

Please sign in to comment.