From f428d6b11ebefcf080de5737448963ed251b18c2 Mon Sep 17 00:00:00 2001 From: robarbon Date: Wed, 2 Mar 2022 16:11:52 +0000 Subject: [PATCH] fixed map_to_integers --- nmpath/auxfunctions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nmpath/auxfunctions.py b/nmpath/auxfunctions.py index 7a7dbd4..1f5c04e 100644 --- a/nmpath/auxfunctions.py +++ b/nmpath/auxfunctions.py @@ -278,10 +278,16 @@ def map_to_integers(sequence, mapping_dict=None): ''' if mapping_dict is None: mapping_dict = {} + counter = 0 + else: + counters = list(mapping_dict.values()) + if len(counters) == 0: + counter = 0 + else: + counter = np.max(counters)+1 new_sequence = np.zeros(len(sequence), dtype='int64') - counter = 0 for i, element in enumerate(sequence): if element not in mapping_dict.keys():