@@ -205,13 +205,13 @@ Graph = R6Class("Graph",
205
205
assert_choice(src_id , names(self $ pipeops ))
206
206
assert_choice(dst_id , names(self $ pipeops ))
207
207
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 ) {
209
209
stopf(" src_channel must not be NULL if src_id pipeop has more than one output channel." )
210
210
}
211
211
src_channel = 1L
212
212
}
213
213
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 ) {
215
215
stopf(" dst_channel must not be NULL if dst_id pipeop has more than one input channel." )
216
216
}
217
217
dst_channel = 1L
@@ -225,7 +225,7 @@ Graph = R6Class("Graph",
225
225
src_channel = self $ pipeops [[src_id ]]$ output $ name [src_channel ]
226
226
}
227
227
assert(
228
- check_integerish(dst_channel , lower = 1 ,
228
+ check_integerish(dst_channel , lower = 1L ,
229
229
upper = nrow(self $ pipeops [[dst_id ]]$ input ), any.missing = FALSE ),
230
230
check_choice(dst_channel , self $ pipeops [[dst_id ]]$ input $ name )
231
231
)
@@ -283,7 +283,7 @@ Graph = R6Class("Graph",
283
283
df = self $ edges [, list (from = src_id , to = dst_id )]
284
284
df = rbind(df , self $ input [, list (from = " <INPUT>" , to = op.id )])
285
285
output = self $ output
286
- if (nrow(output ) > 1 ) {
286
+ if (nrow(output ) > 1L ) {
287
287
# In case we have multiple outputs, we add an output for every final node
288
288
df = rbind(df , output [, list (from = op.id , to = paste0(" <OUTPUT>\n " , name ))])
289
289
} else {
@@ -309,7 +309,7 @@ Graph = R6Class("Graph",
309
309
if (node == " <INPUT>" ) {
310
310
txt = paste0(" Input:<br>Name: " , self $ input $ name , " <br>Train: " , null_str(self $ input $ train ), " <br>Predict: " , null_str(self $ input $ predict ))
311
311
} else if (grepl(" <OUTPUT>" , node )) {
312
- if (nrow(self $ output ) > 1 ) {
312
+ if (nrow(self $ output ) > 1L ) {
313
313
out = self $ output [self $ output $ name == gsub(" <OUTPUT>\n " , " " , node ), ] # Deal with multiple outputs
314
314
} else {
315
315
out = self $ output # Standard case, single output
@@ -342,8 +342,8 @@ Graph = R6Class("Graph",
342
342
if (horizontal ) {
343
343
layout = - layout [, 2 : 1 ]
344
344
}
345
- layout [, 1 ] = layout [, 1 ] * .75
346
- layout [, 2 ] = layout [, 2 ] * .75
345
+ layout [, 1L ] = layout [, 1L ] * .75
346
+ layout [, 2L ] = layout [, 2L ] * .75
347
347
348
348
defaultargs = list (vertex.shape = " crectangle" , vertex.size = 60 , vertex.size2 = 15 * 2.5 , vertex.color = 0 ,
349
349
xlim = range(layout [, 1 ]) + c(- 0.3 , 0.3 ),
@@ -407,7 +407,7 @@ Graph = R6Class("Graph",
407
407
# print table <id>, <state>, where <state> is `class(pipeop$state)`
408
408
lines = rbindlist(map(self $ pipeops [self $ ids(sorted = TRUE )], function (pipeop ) {
409
409
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>" )))
411
411
}), use.names = TRUE )
412
412
if (nrow(lines )) {
413
413
prd = self $ edges [, list (prdcssors = paste(unique(src_id ), collapse = " ," )), by = list (ID = dst_id )]
@@ -420,9 +420,9 @@ Graph = R6Class("Graph",
420
420
outwidth = getOption(" width" ) %??% 80 # output width we want (default 80)
421
421
colwidths = map_int(lines , function (x ) max(nchar(x ), na.rm = TRUE )) # original width of columns
422
422
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 )
426
426
} else {
427
427
cat(" Empty Graph.\n " )
428
428
}
@@ -436,7 +436,7 @@ Graph = R6Class("Graph",
436
436
set_names = function (old , new ) {
437
437
ids = names2(self $ pipeops )
438
438
assert_subset(old , ids )
439
- assert_character(new , any.missing = FALSE , min.chars = 1 )
439
+ assert_character(new , any.missing = FALSE , min.chars = 1L )
440
440
new_ids = map_values(ids , old , new )
441
441
names(self $ pipeops ) = new_ids
442
442
imap(self $ pipeops , function (x , nn ) x $ id = nn )
@@ -465,8 +465,8 @@ Graph = R6Class("Graph",
465
465
},
466
466
467
467
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 )
470
470
}
471
471
),
472
472
@@ -549,8 +549,8 @@ graph_channels = function(ids, channels, pipeops, direction) {
549
549
df $ op.id = po $ id
550
550
df = df [rows ,
551
551
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"
554
554
df
555
555
})
556
556
@@ -606,12 +606,12 @@ graph_reduce = function(self, input, fun, single_input) {
606
606
# inputs differs from the number of channels -- theoretically, there could be two varargs, one
607
607
# getting two inputs, the other none.
608
608
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 ))) {
610
610
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)." )
611
611
}
612
612
# repeat the "..." as often as necessary
613
613
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 )
615
615
} else {
616
616
repeats = nafill(as.numeric(table(names(input ))[graph_input $ name ]), fill = 0 )
617
617
}
@@ -709,7 +709,7 @@ graph_load_namespaces = function(self, info) {
709
709
NULL
710
710
}, error = function (e ) {
711
711
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 )
713
713
})
714
714
})
715
715
errors = discard(errors , is.null )
@@ -725,7 +725,7 @@ predict.Graph = function(object, newdata, ...) {
725
725
stop(" Cannot predict, Graph has not been trained yet" )
726
726
}
727
727
output = object $ output
728
- if (nrow(output ) != 1 ) {
728
+ if (nrow(output ) != 1L ) {
729
729
stop(" Graph has more than one output channel" )
730
730
}
731
731
if (! are_types_compatible(output $ predict , " Prediction" )) {
@@ -751,7 +751,7 @@ predict.Graph = function(object, newdata, ...) {
751
751
)
752
752
}
753
753
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 )
755
755
result = result [[1 ]]
756
756
if (plain ) {
757
757
result = result $ data $ response %??% result $ data $ prob
0 commit comments