Skip to content

Commit 2799a86

Browse files
committed
generalise trans_support_nbreaks() --> support_nbreaks()
1 parent 5872bae commit 2799a86

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

R/scale-.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
745745
if (zero_range(as.numeric(transformation$transform(limits)))) {
746746
breaks <- limits[1]
747747
} else if (is.waive(self$breaks)) {
748-
if (!is.null(self$n.breaks) && trans_support_nbreaks(transformation)) {
748+
if (!is.null(self$n.breaks) && support_nbreaks(transformation$breaks)) {
749749
breaks <- transformation$breaks(limits, self$n.breaks)
750750
} else {
751751
if (!is.null(self$n.breaks)) {
@@ -1237,7 +1237,7 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
12371237
)
12381238
} else if (is.waive(self$breaks)) {
12391239
if (self$nice.breaks) {
1240-
if (!is.null(self$n.breaks) && trans_support_nbreaks(transformation)) {
1240+
if (!is.null(self$n.breaks) && support_nbreaks(transformation$breaks)) {
12411241
breaks <- transformation$breaks(limits, n = self$n.breaks)
12421242
} else {
12431243
if (!is.null(self$n.breaks)) {
@@ -1399,8 +1399,11 @@ check_transformation <- function(x, transformed, name, arg = NULL, call = NULL)
13991399
cli::cli_warn(msg, call = call)
14001400
}
14011401

1402-
trans_support_nbreaks <- function(trans) {
1403-
"n" %in% names(formals(trans$breaks))
1402+
support_nbreaks <- function(fun) {
1403+
if (inherits(fun, "ggproto_method")) {
1404+
fun <- environment(fun)$f
1405+
}
1406+
"n" %in% fn_fmls_names(fun)
14041407
}
14051408

14061409
allow_lambda <- function(x) {

0 commit comments

Comments
 (0)