@@ -559,7 +559,8 @@ def expand_subpaths(self):
559559 for s in range (path_length - k + 1 ):
560560 # Add frequency as a subpath to *first* entry of occurrence
561561 # counter
562- self .paths [k ][path [s :s + k + 1 ]] += np .array ([frequency , 0 ])
562+ path_slice = path [s :s + k + 1 ]
563+ self .paths [k ][path_slice ][0 ] += frequency
563564
564565 def add_path_tuple (self , path , expand_subpaths = True , frequency = np .array ([0 , 1 ])):
565566 """Adds a tuple of elements as a path. If the elements are not strings,
@@ -583,8 +584,9 @@ def add_path_tuple(self, path, expand_subpaths=True, frequency=np.array([0, 1]))
583584 assert path , 'Error: paths needs to contain at least one element'
584585
585586 for x in path :
586- if self .separator in x :
587- raise PathpyError ('Error: Node name contains separator character. Choose different separator.' )
587+ if isinstance (x , str ) and self .separator in x :
588+ raise PathpyError ('Error: Node name contains separator character. '
589+ 'Choose different separator.' )
588590
589591 path_str = path if isinstance (path , str ) else tuple (map (str , path ))
590592
@@ -629,8 +631,9 @@ def add_path_ngram(self, ngram, separator=',', expand_subpaths=True, frequency=N
629631 """
630632 path = tuple (ngram .split (separator ))
631633 for x in path :
632- if self .separator in x :
633- raise PathpyError ('Error: Node name contains separator character. Choose different separator.' )
634+ if isinstance (x , str ) and self .separator in x :
635+ raise PathpyError ('Error: Node name contains separator character.'
636+ 'Choose different separator.' )
634637
635638 path_length = len (path ) - 1
636639
0 commit comments