@@ -444,6 +444,7 @@ Graph = R6Class("Graph",
444444 self $ edges [, c(" src_id" , " dst_id" ) : = list (map_values(src_id , old , new ), map_values(dst_id , old , new ))]
445445 invisible (self )
446446 },
447+
447448 update_ids = function (prefix = " " , postfix = " " ) {
448449 ids = names2(self $ pipeops )
449450 self $ set_names(ids , sprintf(" %s%s%s" , assert_string(prefix ), ids , assert_string(postfix )))
@@ -456,9 +457,13 @@ Graph = R6Class("Graph",
456457 },
457458
458459 predict = function (input , single_input = TRUE ) {
460+ if (! self $ is_trained ) {
461+ stop(" Cannot predict, Graph has not been trained yet" )
462+ }
459463 graph_load_namespaces(self , " predict" )
460464 graph_reduce(self , input , " predict" , single_input )
461465 },
466+
462467 help = function (help_type = getOption(" help_type" )) {
463468 parts = strsplit(self $ man , split = " ::" , fixed = TRUE )[[1 ]]
464469 match.fun(" help" )(parts [[2 ]], package = parts [[1 ]], help_type = help_type )
@@ -717,7 +722,7 @@ graph_load_namespaces = function(self, info) {
717722# ' @export
718723predict.Graph = function (object , newdata , ... ) {
719724 if (! object $ is_trained ) {
720- stop(" Graph is not trained. " )
725+ stop(" Cannot predict, Graph has not been trained yet " )
721726 }
722727 output = object $ output
723728 if (nrow(output ) != 1 ) {
0 commit comments