@@ -690,19 +690,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
690690 if (length(x ) == 0 ) {
691691 return ()
692692 }
693- # Intercept error here to give examples and mention scale in call
694- if (is.factor(x ) || ! typeof(x ) %in% c(" integer" , " double" )) {
695- # These assumptions only hold for standard ContinuousRange class, so
696- # we skip the error if another range class is used
697- if (inherits(self $ range , " ContinuousRange" )) {
698- cli :: cli_abort(
699- c(" Discrete values supplied to continuous scale." ,
700- i = " Example values: {.and {.val {head(x, 5)}}}" ),
701- call = self $ call
702- )
703- }
704- }
705- self $ range $ train(x )
693+ self $ range $ train(x , call = self $ call )
706694 },
707695
708696 is_empty = function (self ) {
@@ -960,19 +948,12 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
960948 if (length(x ) == 0 ) {
961949 return ()
962950 }
963- # Intercept error here to give examples and mention scale in call
964- if (! is.discrete(x )) {
965- # These assumptions only hold for standard DiscreteRange class, so
966- # we skip the error if another range class is used
967- if (inherits(self $ range , " DiscreteRange" )) {
968- cli :: cli_abort(
969- c(" Continuous values supplied to discrete scale." ,
970- i = " Example values: {.and {.val {head(x, 5)}}}" ),
971- call = self $ call
972- )
973- }
974- }
975- self $ range $ train(x , drop = self $ drop , na.rm = ! self $ na.translate )
951+ self $ range $ train(
952+ x ,
953+ drop = self $ drop ,
954+ na.rm = ! self $ na.translate ,
955+ call = self $ call
956+ )
976957 },
977958
978959 transform = identity ,
@@ -1185,17 +1166,16 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
11851166 is_discrete = function () FALSE ,
11861167
11871168 train = function (self , x ) {
1169+ if (length(x ) == 0 ) {
1170+ return ()
1171+ }
11881172 if (! is.numeric(x )) {
11891173 cli :: cli_abort(
11901174 " Binned scales only support continuous data." ,
11911175 call = self $ call
11921176 )
11931177 }
1194-
1195- if (length(x ) == 0 ) {
1196- return ()
1197- }
1198- self $ range $ train(x )
1178+ self $ range $ train(x , call = self $ call )
11991179 },
12001180
12011181 transform = default_transform ,
0 commit comments