From 0c30411bbdd40aed59267a904d34f6e4e3e9fb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Vel=C3=A1squez?= Date: Sun, 16 Jun 2024 19:44:00 -0400 Subject: [PATCH 1/4] Pass dots to `vec_math_base()` --- NEWS.md | 3 ++- R/num.R | 2 +- tests/testthat/_snaps/num.md | 5 +++++ tests/testthat/test-num.R | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 02d24a095..ae3ed53ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,8 +2,9 @@ # pillar 1.9.0.9008 -- Internal changes only. +## Bug fixes +- Math operations on `num()` objects now pass additional arguments to the mathematical function (@gvelasq, #660). # pillar 1.9.0.9007 diff --git a/R/num.R b/R/num.R index 00dfeb66c..81179e10a 100644 --- a/R/num.R +++ b/R/num.R @@ -127,7 +127,7 @@ vec_arith.numeric.pillar_num <- vec_arith.pillar_num.default vec_math.pillar_num <- function(.fn, .x, ...) { "!!!!DEBUG vec_math(`v(.fn)`)" - out <- vec_math_base(.fn, vec_proxy(.x)) + out <- vec_math_base(.fn, vec_proxy(.x), ...) if (is.numeric(out)) { out <- vec_restore(out, .x) diff --git a/tests/testthat/_snaps/num.md b/tests/testthat/_snaps/num.md index e4d684c4b..e9a0473c2 100644 --- a/tests/testthat/_snaps/num.md +++ b/tests/testthat/_snaps/num.md @@ -467,6 +467,11 @@ Output [1] 84.1 90.9 14.1 + Code + sum(num(c(1:3, NA)), na.rm = TRUE) + Output + + [1] 6 # formatting diff --git a/tests/testthat/test-num.R b/tests/testthat/test-num.R index 759bbb271..dd207ad48 100644 --- a/tests/testthat/test-num.R +++ b/tests/testthat/test-num.R @@ -170,6 +170,7 @@ test_that("mathematics", { min(num(1:3, label = "$")) mean(num(1:3, notation = "eng")) sin(num(1:3, label = "%", scale = 100)) + sum(num(c(1:3, NA)), na.rm = TRUE) }) }) From 918789994000c529687ba5b83d3177f6f1bf1579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Vel=C3=A1squez?= Date: Fri, 21 Jun 2024 00:08:52 +0200 Subject: [PATCH 2/4] Revert NEWS.md --- NEWS.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index ae3ed53ff..02d24a095 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,9 +2,8 @@ # pillar 1.9.0.9008 -## Bug fixes +- Internal changes only. -- Math operations on `num()` objects now pass additional arguments to the mathematical function (@gvelasq, #660). # pillar 1.9.0.9007 From d5d8875272c4220123bade381c97e285f3d9cf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Vel=C3=A1squez?= Date: Fri, 21 Jun 2024 00:10:17 +0200 Subject: [PATCH 3/4] Fix test for `scale_y_num()` --- tests/testthat/test-ggplot2.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-ggplot2.R b/tests/testthat/test-ggplot2.R index 9c223847f..8486ea2f5 100644 --- a/tests/testthat/test-ggplot2.R +++ b/tests/testthat/test-ggplot2.R @@ -19,7 +19,7 @@ test_that("ggplot2 snapshot tests", { log_scale <- ggplot2::ggplot(data, ggplot2::aes(x, z)) + ggplot2::geom_point() + - scale_y_num(trans = "log10") + + scale_y_num(transform = "log10") + ggplot2::theme_minimal(36) vdiffr::expect_doppelganger("log_scale", log_scale) From 784546d632b01e0f910c090ed50d2fbe844473a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Mon, 24 Jun 2024 04:44:47 +0200 Subject: [PATCH 4/4] Accept snapshot --- tests/testthat/_snaps/ggplot2/log-scale.svg | 84 ++++++++++----------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/tests/testthat/_snaps/ggplot2/log-scale.svg b/tests/testthat/_snaps/ggplot2/log-scale.svg index 14010270d..89530a950 100644 --- a/tests/testthat/_snaps/ggplot2/log-scale.svg +++ b/tests/testthat/_snaps/ggplot2/log-scale.svg @@ -20,54 +20,50 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + -10n -1m -100 -10M -25 -50 -75 -100 -x - [ -10 --3 -] +1m +1 +1k +25 +50 +75 +100 +x + [ +10 +-3 +] z -log_scale +log_scale