diff --git a/NEWS.md b/NEWS.md index bf9188e..506f2f1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # bench (development version) +* Fixed an issue in `bench_time_trans()` and `bench_bytes_trans()` where pretty + breaks were not being applied correctly (#140, @plietar, @simonpcouch). + * R >=4.0.0 is now required, which is aligned with tidyverse standards. * Switched to modern ggplot2 conventions internally (#141, @olivroy). diff --git a/R/bytes.R b/R/bytes.R index 61d9612..effcbe3 100644 --- a/R/bytes.R +++ b/R/bytes.R @@ -169,16 +169,25 @@ type_sum.bench_bytes <- function(x) { bench_bytes_trans <- function(base = 2) { if (is.null(base)) { return( - scales::trans_new("bch:byt", as.numeric, as_bench_bytes, - scales::pretty_breaks(), domain = c(1e-100, Inf) + scales::trans_new( + name = "bch:byt", + transform = as.numeric, + inverse = as_bench_bytes, + breaks = scales::pretty_breaks(), + domain = c(1e-100, Inf) ) ) } trans <- function(x) log(as.numeric(x), base) inv <- function(x) as_bench_bytes(base ^ as.numeric(x)) - scales::trans_new(paste0("bch:byt-", format(base)), trans, inv, - scales::log_breaks(base = base), domain = c(1e-100, Inf)) + scales::trans_new( + name = paste0("bch:byt-", format(base)), + transform = trans, + inverse = inv, + breaks = scales::log_breaks(base = base), + domain = c(1e-100, Inf) + ) } # Lazily registered in `.onLoad()` diff --git a/R/time.R b/R/time.R index b8b4579..ae3dbd8 100644 --- a/R/time.R +++ b/R/time.R @@ -209,8 +209,12 @@ type_sum.bench_time <- function(x) { bench_time_trans <- function(base = 10) { if (is.null(base)) { return( - scales::trans_new("bch:tm", as.numeric, as_bench_time, - scales::pretty_breaks(), domain = c(1e-100, Inf) + scales::trans_new( + name = "bch:tm", + transform = as.numeric, + inverse = as_bench_time, + breaks = scales::pretty_breaks(), + domain = c(1e-100, Inf) ) ) } @@ -218,8 +222,13 @@ bench_time_trans <- function(base = 10) { trans <- function(x) log(as.numeric(x), base) inv <- function(x) as_bench_time(base ^ as.numeric(x)) - scales::trans_new(paste0("bch:tm-", format(base)), trans, inv, - scales::log_breaks(base = base), domain = c(1e-100, Inf)) + scales::trans_new( + name = paste0("bch:tm-", format(base)), + transform = trans, + inverse = inv, + breaks = scales::log_breaks(base = base), + domain = c(1e-100, Inf) + ) } # Lazily registered in `.onLoad()`