@@ -205,13 +205,13 @@ Graph = R6Class("Graph",
205205 assert_choice(src_id , names(self $ pipeops ))
206206 assert_choice(dst_id , names(self $ pipeops ))
207207 if (is.null(src_channel )) {
208- if (length(self $ pipeops [[src_id ]]$ output $ name ) > 1 ) {
208+ if (length(self $ pipeops [[src_id ]]$ output $ name ) > 1L ) {
209209 stopf(" src_channel must not be NULL if src_id pipeop has more than one output channel." )
210210 }
211211 src_channel = 1L
212212 }
213213 if (is.null(dst_channel )) {
214- if (length(self $ pipeops [[dst_id ]]$ input $ name ) > 1 ) {
214+ if (length(self $ pipeops [[dst_id ]]$ input $ name ) > 1L ) {
215215 stopf(" dst_channel must not be NULL if dst_id pipeop has more than one input channel." )
216216 }
217217 dst_channel = 1L
@@ -225,7 +225,7 @@ Graph = R6Class("Graph",
225225 src_channel = self $ pipeops [[src_id ]]$ output $ name [src_channel ]
226226 }
227227 assert(
228- check_integerish(dst_channel , lower = 1 ,
228+ check_integerish(dst_channel , lower = 1L ,
229229 upper = nrow(self $ pipeops [[dst_id ]]$ input ), any.missing = FALSE ),
230230 check_choice(dst_channel , self $ pipeops [[dst_id ]]$ input $ name )
231231 )
@@ -283,7 +283,7 @@ Graph = R6Class("Graph",
283283 df = self $ edges [, list (from = src_id , to = dst_id )]
284284 df = rbind(df , self $ input [, list (from = " <INPUT>" , to = op.id )])
285285 output = self $ output
286- if (nrow(output ) > 1 ) {
286+ if (nrow(output ) > 1L ) {
287287 # In case we have multiple outputs, we add an output for every final node
288288 df = rbind(df , output [, list (from = op.id , to = paste0(" <OUTPUT>\n " , name ))])
289289 } else {
@@ -309,7 +309,7 @@ Graph = R6Class("Graph",
309309 if (node == " <INPUT>" ) {
310310 txt = paste0(" Input:<br>Name: " , self $ input $ name , " <br>Train: " , null_str(self $ input $ train ), " <br>Predict: " , null_str(self $ input $ predict ))
311311 } else if (grepl(" <OUTPUT>" , node )) {
312- if (nrow(self $ output ) > 1 ) {
312+ if (nrow(self $ output ) > 1L ) {
313313 out = self $ output [self $ output $ name == gsub(" <OUTPUT>\n " , " " , node ), ] # Deal with multiple outputs
314314 } else {
315315 out = self $ output # Standard case, single output
@@ -342,8 +342,8 @@ Graph = R6Class("Graph",
342342 if (horizontal ) {
343343 layout = - layout [, 2 : 1 ]
344344 }
345- layout [, 1 ] = layout [, 1 ] * .75
346- layout [, 2 ] = layout [, 2 ] * .75
345+ layout [, 1L ] = layout [, 1L ] * .75
346+ layout [, 2L ] = layout [, 2L ] * .75
347347
348348 defaultargs = list (vertex.shape = " crectangle" , vertex.size = 60 , vertex.size2 = 15 * 2.5 , vertex.color = 0 ,
349349 xlim = range(layout [, 1 ]) + c(- 0.3 , 0.3 ),
@@ -407,7 +407,7 @@ Graph = R6Class("Graph",
407407 # print table <id>, <state>, where <state> is `class(pipeop$state)`
408408 lines = rbindlist(map(self $ pipeops [self $ ids(sorted = TRUE )], function (pipeop ) {
409409 data.table(ID = pipeop $ id , State = sprintf(" <%s>" ,
410- map_values(class(pipeop $ state )[1 ], " NULL" , " <UNTRAINED>" )))
410+ map_values(class(pipeop $ state )[1L ], " NULL" , " <UNTRAINED>" )))
411411 }), use.names = TRUE )
412412 if (nrow(lines )) {
413413 prd = self $ edges [, list (prdcssors = paste(unique(src_id ), collapse = " ," )), by = list (ID = dst_id )]
@@ -420,9 +420,9 @@ Graph = R6Class("Graph",
420420 outwidth = getOption(" width" ) %??% 80 # output width we want (default 80)
421421 colwidths = map_int(lines , function (x ) max(nchar(x ), na.rm = TRUE )) # original width of columns
422422 collimit = calculate_collimit(colwidths , outwidth )
423- with_options( list ( datatable.prettyprint.char = collimit ), {
424- print( lines , row.names = FALSE )
425- } )
423+ opts = options( datatable.prettyprint.char = collimit )
424+ on.exit(options( opts ), add = TRUE )
425+ print( lines , row.names = FALSE )
426426 } else {
427427 cat(" Empty Graph.\n " )
428428 }
@@ -436,7 +436,7 @@ Graph = R6Class("Graph",
436436 set_names = function (old , new ) {
437437 ids = names2(self $ pipeops )
438438 assert_subset(old , ids )
439- assert_character(new , any.missing = FALSE , min.chars = 1 )
439+ assert_character(new , any.missing = FALSE , min.chars = 1L )
440440 new_ids = map_values(ids , old , new )
441441 names(self $ pipeops ) = new_ids
442442 imap(self $ pipeops , function (x , nn ) x $ id = nn )
@@ -465,8 +465,8 @@ Graph = R6Class("Graph",
465465 },
466466
467467 help = function (help_type = getOption(" help_type" )) {
468- parts = strsplit(self $ man , split = " ::" , fixed = TRUE )[[1 ]]
469- match.fun(" help" )(parts [[2 ]], package = parts [[1 ]], help_type = help_type )
468+ parts = strsplit(self $ man , split = " ::" , fixed = TRUE )[[1L ]]
469+ match.fun(" help" )(parts [[2L ]], package = parts [[1L ]], help_type = help_type )
470470 }
471471 ),
472472
@@ -549,8 +549,8 @@ graph_channels = function(ids, channels, pipeops, direction) {
549549 df $ op.id = po $ id
550550 df = df [rows ,
551551 c(" name" , " train" , " predict" , " op.id" , " name" )]
552- df [[1 ]] = paste0(po $ id , " ." , df [[1 ]])
553- names(df )[5 ] = " channel.name"
552+ df [[1L ]] = paste0(po $ id , " ." , df [[1L ]])
553+ names(df )[5L ] = " channel.name"
554554 df
555555 })
556556
@@ -606,12 +606,12 @@ graph_reduce = function(self, input, fun, single_input) {
606606 # inputs differs from the number of channels -- theoretically, there could be two varargs, one
607607 # getting two inputs, the other none.
608608 if (! single_input && " ..." %in% graph_input $ channel.name ) {
609- if (sum(" ..." == graph_input $ channel.name ) != 1 && is.null(names(input ))) {
609+ if (sum(" ..." == graph_input $ channel.name ) != 1L && is.null(names(input ))) {
610610 stop(" Ambiguous distribution of inputs to vararg channels.\n Assigning more than one input to vararg channels when there are multiple vararg inputs does not work.\n You can try using a named input list. Vararg elements must be named '<pipeopname>....' (with four dots)." )
611611 }
612612 # repeat the "..." as often as necessary
613613 if (is.null(names(input ))) {
614- repeats = ifelse(graph_input $ channel.name == " ..." , length(input ) - nrow(graph_input ) + 1 , 1 )
614+ repeats = ifelse(graph_input $ channel.name == " ..." , length(input ) - nrow(graph_input ) + 1L , 1L )
615615 } else {
616616 repeats = nafill(as.numeric(table(names(input ))[graph_input $ name ]), fill = 0 )
617617 }
@@ -709,7 +709,7 @@ graph_load_namespaces = function(self, info) {
709709 NULL
710710 }, error = function (e ) {
711711 sprintf(" Error loading package %s (required by %s):\n %s" ,
712- package , str_collapse(pipeops , n = 4 ), e $ message )
712+ package , str_collapse(pipeops , n = 4L ), e $ message )
713713 })
714714 })
715715 errors = discard(errors , is.null )
@@ -725,7 +725,7 @@ predict.Graph = function(object, newdata, ...) {
725725 stop(" Cannot predict, Graph has not been trained yet" )
726726 }
727727 output = object $ output
728- if (nrow(output ) != 1 ) {
728+ if (nrow(output ) != 1L ) {
729729 stop(" Graph has more than one output channel" )
730730 }
731731 if (! are_types_compatible(output $ predict , " Prediction" )) {
@@ -751,7 +751,7 @@ predict.Graph = function(object, newdata, ...) {
751751 )
752752 }
753753 result = object $ predict(newdata )
754- assert_list(result , types = " Prediction" , any.missing = FALSE , len = 1 )
754+ assert_list(result , types = " Prediction" , any.missing = FALSE , len = 1L )
755755 result = result [[1 ]]
756756 if (plain ) {
757757 result = result $ data $ response %??% result $ data $ prob
0 commit comments