@@ -690,19 +690,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
690
690
if (length(x ) == 0 ) {
691
691
return ()
692
692
}
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 )
706
694
},
707
695
708
696
is_empty = function (self ) {
@@ -960,19 +948,12 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
960
948
if (length(x ) == 0 ) {
961
949
return ()
962
950
}
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
+ )
976
957
},
977
958
978
959
transform = identity ,
@@ -1185,17 +1166,16 @@ ScaleBinned <- ggproto("ScaleBinned", Scale,
1185
1166
is_discrete = function () FALSE ,
1186
1167
1187
1168
train = function (self , x ) {
1169
+ if (length(x ) == 0 ) {
1170
+ return ()
1171
+ }
1188
1172
if (! is.numeric(x )) {
1189
1173
cli :: cli_abort(
1190
1174
" Binned scales only support continuous data." ,
1191
1175
call = self $ call
1192
1176
)
1193
1177
}
1194
-
1195
- if (length(x ) == 0 ) {
1196
- return ()
1197
- }
1198
- self $ range $ train(x )
1178
+ self $ range $ train(x , call = self $ call )
1199
1179
},
1200
1180
1201
1181
transform = default_transform ,
0 commit comments