Skip to content

Commit f625c02

Browse files
committed
pass on calls
1 parent 3aec34a commit f625c02

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

R/scale-.R

+11-31
Original file line numberDiff line numberDiff line change
@@ -684,19 +684,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
684684
if (length(x) == 0) {
685685
return()
686686
}
687-
# Intercept error here to give examples and mention scale in call
688-
if (is.factor(x) || !typeof(x) %in% c("integer", "double")) {
689-
# These assumptions only hold for standard ContinuousRange class, so
690-
# we skip the error if another range class is used
691-
if (inherits(self$range, "ContinuousRange")) {
692-
cli::cli_abort(
693-
c("Discrete values supplied to continuous scale.",
694-
i = "Example values: {.and {.val {head(x, 5)}}}"),
695-
call = self$call
696-
)
697-
}
698-
}
699-
self$range$train(x)
687+
self$range$train(x, call = self$call)
700688
},
701689

702690
is_empty = function(self) {
@@ -964,19 +952,12 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
964952
if (length(x) == 0) {
965953
return()
966954
}
967-
# Intercept error here to give examples and mention scale in call
968-
if (!is.discrete(x)) {
969-
# These assumptions only hold for standard DiscreteRange class, so
970-
# we skip the error if another range class is used
971-
if (inherits(self$range, "DiscreteRange")) {
972-
cli::cli_abort(
973-
c("Continuous values supplied to discrete scale.",
974-
i = "Example values: {.and {.val {head(x, 5)}}}"),
975-
call = self$call
976-
)
977-
}
978-
}
979-
self$range$train(x, drop = self$drop, na.rm = !self$na.translate)
955+
self$range$train(
956+
x,
957+
drop = self$drop,
958+
na.rm = !self$na.translate,
959+
call = self$call
960+
)
980961
},
981962

982963
transform = identity,
@@ -1196,17 +1177,16 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
11961177
is_discrete = function() FALSE,
11971178

11981179
train = function(self, x) {
1180+
if (length(x) == 0) {
1181+
return()
1182+
}
11991183
if (!is.numeric(x)) {
12001184
cli::cli_abort(
12011185
"Binned scales only support continuous data.",
12021186
call = self$call
12031187
)
12041188
}
1205-
1206-
if (length(x) == 0) {
1207-
return()
1208-
}
1209-
self$range$train(x)
1189+
self$range$train(x, call = self$call)
12101190
},
12111191

12121192
transform = default_transform,

0 commit comments

Comments
 (0)