@@ -258,6 +258,8 @@ def clear_attributes(self): # @todo: update
258258 delattr (self , '_Y' )
259259 if hasattr (self , '_run_time' ):
260260 delattr (self , '_run_time' )
261+ if hasattr (self , '_test_run_time' ):
262+ delattr (self , '_test_run_time' )
261263
262264
263265 def validate_parameters (self ):
@@ -330,24 +332,26 @@ def compute_distance_matrix(self, Y=None, **kwargs):
330332
331333 else :
332334 # Compute kernel matrix between Y and self._graphs (X).
335+ Y_copy = ([g .copy () for g in Y ] if self .copy_graphs else Y )
336+ graphs_copy = ([g .copy () for g in
337+ self ._graphs ] if self .copy_graphs else self ._graphs )
338+
333339 start_time = time .time ()
334340
335341 if self .parallel == 'imap_unordered' :
336342 dis_matrix = self ._compute_distance_matrix_imap_unordered (Y )
337343
338344 elif self .parallel is None :
339- Y_copy = ([g .copy () for g in Y ] if self .copy_graphs else Y )
340- graphs_copy = ([g .copy () for g in
341- self ._graphs ] if self .copy_graphs else self ._graphs )
342345 dis_matrix = self ._compute_distance_matrix_series (
343346 Y_copy , graphs_copy , ** kwargs
344347 )
345348
346- self ._run_time = time .time () - start_time
349+ self ._test_run_time = time .time () - start_time
350+
347351 if self .verbose :
348352 print (
349353 'Distance matrix of size (%d, %d) built in %s seconds.'
350- % (len (Y ), len (self ._graphs ), self ._run_time )
354+ % (len (Y ), len (self ._graphs ), self ._test_run_time )
351355 )
352356
353357 return dis_matrix
@@ -620,10 +624,11 @@ def compute_edit_costs(self, Y=None, Y_targets=None, **kwargs):
620624 # return dis_mat, dis_max, dis_min, dis_mean
621625
622626 def _compute_X_distance_matrix (self , ** kwargs ):
623- start_time = time .time ()
624-
625627 graphs = ([g .copy () for g in
626628 self ._graphs ] if self .copy_graphs else self ._graphs )
629+
630+ start_time = time .time ()
631+
627632 if self .parallel == 'imap_unordered' :
628633 dis_matrix = self ._compute_X_dm_imap_unordered (graphs , ** kwargs )
629634 elif self .parallel is None :
@@ -632,6 +637,7 @@ def _compute_X_distance_matrix(self, **kwargs):
632637 raise Exception ('Parallel mode is not set correctly.' )
633638
634639 self ._run_time = time .time () - start_time
640+
635641 if self .verbose :
636642 print (
637643 'Distance matrix of size %d built in %s seconds.'
@@ -646,7 +652,7 @@ def _compute_X_dm_series(self, graphs, **kwargs):
646652 dis_matrix = np .zeros ((n , n ))
647653
648654 iterator = combinations (range (n ), 2 )
649- len_itr = int (n * (n + 1 ) / 2 )
655+ len_itr = int (n * (n - 1 ) / 2 )
650656 if self .verbose :
651657 print ('Graphs in total: %d.' % len (graphs ))
652658 print ('The total # of pairs is %d.' % len_itr )
@@ -780,6 +786,26 @@ def is_graph(self, graph):
780786 if isinstance (graph , nx .MultiDiGraph ):
781787 return True
782788 return False
789+
790+
791+ def __repr__ (self ):
792+ return (
793+ f"{ self .__class__ .__name__ } ("
794+ f"optim_method={ self .optim_method } , "
795+ f"ed_method={ self .ed_method } , "
796+ f"edit_cost_fun={ self .edit_cost_fun } , "
797+ f"node_labels={ self .node_labels } , "
798+ f"edge_labels={ self .edge_labels } , "
799+ f"optim_options={ self .optim_options } , "
800+ f"init_edit_cost_constants={ self .init_edit_cost_constants } , "
801+ f"copy_graphs={ self .copy_graphs } , "
802+ f"parallel={ self .parallel } , "
803+ f"n_jobs={ self .n_jobs } , "
804+ f"verbose={ self .verbose } , "
805+ f"normalize={ self .normalize } , "
806+ f"run_time={ self .run_time } "
807+ f")"
808+ )
783809
784810
785811 @property
@@ -807,15 +833,18 @@ def graphs(self):
807833 def run_time (self ):
808834 return self ._run_time
809835
836+ @property
837+ def test_run_time (self ):
838+ return self ._test_run_time
810839
811840 @property
812841 def dis_matrix (self ):
813- return self ._dis_matrix
842+ return self ._dm_train
814843
815844
816845 @dis_matrix .setter
817846 def dis_matrix (self , value ):
818- self ._dis_matrix = value
847+ self ._dm_train = value
819848
820849
821850 @property
0 commit comments