Skip to content

Commit

Permalink
Tweak formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Jan 16, 2025
1 parent 5fa82c8 commit db1c87c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions R/bytes.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,25 @@ type_sum.bench_bytes <- function(x) {
bench_bytes_trans <- function(base = 2) {
if (is.null(base)) {
return(
scales::trans_new("bch:byt", transform = as.numeric,
inverse = as_bench_bytes, breaks = scales::pretty_breaks(),
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)), transform = trans,
inverse = inv, breaks = 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()`
Expand Down
17 changes: 12 additions & 5 deletions R/time.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ type_sum.bench_time <- function(x) {
bench_time_trans <- function(base = 10) {
if (is.null(base)) {
return(
scales::trans_new("bch:tm", transform = as.numeric,
inverse = as_bench_time, breaks = scales::pretty_breaks(),
scales::trans_new(
name = "bch:tm",
transform = as.numeric,
inverse = as_bench_time,
breaks = scales::pretty_breaks(),
domain = c(1e-100, Inf)
)
)
Expand All @@ -219,9 +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)), transform = trans,
inverse = inv, breaks = 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()`
Expand Down

0 comments on commit db1c87c

Please sign in to comment.