Skip to content

Commit

Permalink
Use @exportS3Method over s3_register().
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Feb 21, 2024
1 parent 3618bd9 commit a913cb4
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 208 deletions.
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ S3method(as_bench_bytes,numeric)
S3method(as_bench_time,bench_time)
S3method(as_bench_time,default)
S3method(as_bench_time,numeric)
S3method(dplyr::filter,bench_mark)
S3method(dplyr::group_by,bench_mark)
S3method(format,bench_bytes)
S3method(format,bench_expr)
S3method(format,bench_time)
S3method(ggplot2::autoplot,bench_mark)
S3method(ggplot2::scale_type,bench_bytes)
S3method(ggplot2::scale_type,bench_expr)
S3method(ggplot2::scale_type,bench_time)
S3method(knitr::knit_print,bench_mark)
S3method(max,bench_bytes)
S3method(max,bench_time)
S3method(mean,bench_time)
Expand All @@ -37,9 +44,12 @@ S3method(rbind,bench_mark)
S3method(sum,bench_bytes)
S3method(sum,bench_time)
S3method(summary,bench_mark)
S3method(tidyr::unnest,bench_mark)
S3method(type_sum,bench_bytes)
S3method(type_sum,bench_expr)
S3method(type_sum,bench_time)
S3method(vctrs::vec_proxy,bench_expr)
S3method(vctrs::vec_restore,bench_expr)
export(as_bench_bytes)
export(as_bench_mark)
export(as_bench_time)
Expand Down
1 change: 1 addition & 0 deletions R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#' autoplot("violin")
#' }
#' }
#' @exportS3Method ggplot2::autoplot
autoplot.bench_mark <- function(object,
type = c("beeswarm", "jitter", "ridge", "boxplot", "violin"),...) {

Expand Down
1 change: 1 addition & 0 deletions R/bytes.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ bench_bytes_trans <- function(base = 2) {
scales::log_breaks(base = base), domain = c(1e-100, Inf))
}

#' @exportS3Method ggplot2::scale_type
scale_type.bench_bytes <- function(x) "bench_bytes"

#' Position scales for bench_time data
Expand Down
5 changes: 3 additions & 2 deletions R/expression.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ type_sum.bench_expr <- function(x) {
new_bench_expr(new_x)
}

# @export
#' @exportS3Method vctrs::vec_proxy
vec_proxy.bench_expr <- function(x, ...) {
desc <- attr(x, "description")
attributes(x) <- NULL
out <- list(x = x, desc = desc)
vctrs::new_data_frame(out, n = length(x))
}

# @export
#' @exportS3Method vctrs::vec_restore
vec_restore.bench_expr <- function(x, to, ...) {
new_bench_expr(x$x, x$desc)
}
Expand All @@ -55,6 +55,7 @@ pillar_shaft.bench_expr <- function(x, ...) {
pillar_shaft(as.character(x), ...)
}

#' @exportS3Method ggplot2::scale_type
scale_type.bench_expr <- function(x) {
"bench_expr"
}
Expand Down
187 changes: 0 additions & 187 deletions R/import-standalone-s3-register.R

This file was deleted.

4 changes: 4 additions & 0 deletions R/mark.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ parse_allocations <- function(filename) {
#'
#' @param options A list of knitr chunk options set in the currently evaluated
#' chunk.
#' @exportS3Method knitr::knit_print
knit_print.bench_mark <- function(x, ..., options) {
if (!isTRUE(options$bench.all_columns)) {
x <- x[!colnames(x) %in% data_cols]
Expand All @@ -339,6 +340,7 @@ parse_gc <- function(x) {

utils::globalVariables(c("time", "gc"))

#' @exportS3Method tidyr::unnest
unnest.bench_mark <- function(data, ...) {
if (inherits(data[["expression"]], "bench_expr")) {
data[["expression"]] <- as.character(data[["expression"]])
Expand Down Expand Up @@ -376,12 +378,14 @@ rbind.bench_mark <- function(..., deparse.level = 1) {
res
}

#' @exportS3Method dplyr::filter
filter.bench_mark <- function(.data, ...) {
dots <- rlang::quos(...)
idx <- Reduce(`&`, lapply(dots, rlang::eval_tidy, data = .data))
.data[idx, ]
}

#' @exportS3Method dplyr::group_by
group_by.bench_mark <- function(.data, ...) {
bench_mark(NextMethod())
}
1 change: 1 addition & 0 deletions R/time.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ bench_time_trans <- function(base = 10) {
scales::log_breaks(base = base), domain = c(1e-100, Inf))
}

#' @exportS3Method ggplot2::scale_type
scale_type.bench_time <- function(x) "bench_time"

#' Position scales for bench_time data
Expand Down
17 changes: 0 additions & 17 deletions R/zzz.R

This file was deleted.

2 changes: 1 addition & 1 deletion man/autoplot.bench_mark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/knit_print.bench_mark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a913cb4

Please sign in to comment.