diff --git a/docs/pyerrors/input/utils.html b/docs/pyerrors/input/utils.html index 35d788be..eca6864f 100644 --- a/docs/pyerrors/input/utils.html +++ b/docs/pyerrors/input/utils.html @@ -99,61 +99,63 @@ 18 sorted list 19 """ 20 if len(ll) > 1: -21 r_pattern = r'r(\d+)' -22 id_pattern = r'id(\d+)' -23 -24 # sort list by id first -25 if all([re.search(id_pattern, entry) for entry in ll]): -26 ll.sort(key=lambda x: int(re.findall(id_pattern, x)[0])) -27 # then by replikum -28 if all([re.search(r_pattern, entry) for entry in ll]): -29 ll.sort(key=lambda x: int(re.findall(r_pattern, x)[0])) -30 # as the rearrangements by one key let the other key untouched, the list is sorted now -31 -32 else: -33 # fallback -34 sames = '' -35 if len(ll) > 1: -36 for i in range(len(ll[0])): -37 checking = ll[0][i] -38 for rn in ll[1:]: -39 is_same = (rn[i] == checking) -40 if is_same: -41 sames += checking -42 else: -43 break -44 print("Using prefix:", ll[0][len(sames):]) -45 ll.sort(key=lambda x: int(re.findall(r'\d+', x[len(sames):])[0])) -46 return ll -47 -48 -49def check_idl(idl, che): -50 """Checks if list of configurations is contained in an idl -51 -52 Parameters -53 ---------- -54 idl : range or list -55 idl of the current replicum -56 che : list -57 list of configurations to be checked against -58 -59 Returns -60 ------- -61 miss_str : str -62 string with integers of which idls are missing -63 """ -64 missing = [] -65 for c in che: -66 if c not in idl: -67 missing.append(c) -68 # print missing configurations such that it can directly be parsed to slurm terminal -69 if not (len(missing) == 0): -70 print(len(missing), "configs missing") -71 miss_str = str(missing[0]) -72 for i in missing[1:]: -73 miss_str += "," + str(i) -74 print(miss_str) -75 return miss_str +21 sorted = False +22 r_pattern = r'r(\d+)' +23 id_pattern = r'id(\d+)' +24 +25 # sort list by id first +26 if all([re.search(id_pattern, entry) for entry in ll]): +27 ll.sort(key=lambda x: int(re.findall(id_pattern, x)[0])) +28 sorted = True +29 # then by replikum +30 if all([re.search(r_pattern, entry) for entry in ll]): +31 ll.sort(key=lambda x: int(re.findall(r_pattern, x)[0])) +32 sorted = True +33 # as the rearrangements by one key let the other key untouched, the list is sorted now +34 +35 if not sorted: +36 # fallback +37 sames = '' +38 for i in range(len(ll[0])): +39 checking = ll[0][i] +40 for rn in ll[1:]: +41 is_same = (rn[i] == checking) +42 if is_same: +43 sames += checking +44 else: +45 break +46 print("Using prefix:", sames) +47 ll.sort(key=lambda x: int(re.findall(r'\d+', x[len(sames):])[0])) +48 return ll +49 +50 +51def check_idl(idl, che): +52 """Checks if list of configurations is contained in an idl +53 +54 Parameters +55 ---------- +56 idl : range or list +57 idl of the current replicum +58 che : list +59 list of configurations to be checked against +60 +61 Returns +62 ------- +63 miss_str : str +64 string with integers of which idls are missing +65 """ +66 missing = [] +67 for c in che: +68 if c not in idl: +69 missing.append(c) +70 # print missing configurations such that it can directly be parsed to slurm terminal +71 if not (len(missing) == 0): +72 print(len(missing), "configs missing") +73 miss_str = str(missing[0]) +74 for i in missing[1:]: +75 miss_str += "," + str(i) +76 print(miss_str) +77 return miss_str @@ -185,32 +187,34 @@ 19 sorted list 20 """ 21 if len(ll) > 1: -22 r_pattern = r'r(\d+)' -23 id_pattern = r'id(\d+)' -24 -25 # sort list by id first -26 if all([re.search(id_pattern, entry) for entry in ll]): -27 ll.sort(key=lambda x: int(re.findall(id_pattern, x)[0])) -28 # then by replikum -29 if all([re.search(r_pattern, entry) for entry in ll]): -30 ll.sort(key=lambda x: int(re.findall(r_pattern, x)[0])) -31 # as the rearrangements by one key let the other key untouched, the list is sorted now -32 -33 else: -34 # fallback -35 sames = '' -36 if len(ll) > 1: -37 for i in range(len(ll[0])): -38 checking = ll[0][i] -39 for rn in ll[1:]: -40 is_same = (rn[i] == checking) -41 if is_same: -42 sames += checking -43 else: -44 break -45 print("Using prefix:", ll[0][len(sames):]) -46 ll.sort(key=lambda x: int(re.findall(r'\d+', x[len(sames):])[0])) -47 return ll +22 sorted = False +23 r_pattern = r'r(\d+)' +24 id_pattern = r'id(\d+)' +25 +26 # sort list by id first +27 if all([re.search(id_pattern, entry) for entry in ll]): +28 ll.sort(key=lambda x: int(re.findall(id_pattern, x)[0])) +29 sorted = True +30 # then by replikum +31 if all([re.search(r_pattern, entry) for entry in ll]): +32 ll.sort(key=lambda x: int(re.findall(r_pattern, x)[0])) +33 sorted = True +34 # as the rearrangements by one key let the other key untouched, the list is sorted now +35 +36 if not sorted: +37 # fallback +38 sames = '' +39 for i in range(len(ll[0])): +40 checking = ll[0][i] +41 for rn in ll[1:]: +42 is_same = (rn[i] == checking) +43 if is_same: +44 sames += checking +45 else: +46 break +47 print("Using prefix:", sames) +48 ll.sort(key=lambda x: int(re.findall(r'\d+', x[len(sames):])[0])) +49 return ll @@ -246,33 +250,33 @@ sorted list -
50def check_idl(idl, che): -51 """Checks if list of configurations is contained in an idl -52 -53 Parameters -54 ---------- -55 idl : range or list -56 idl of the current replicum -57 che : list -58 list of configurations to be checked against -59 -60 Returns -61 ------- -62 miss_str : str -63 string with integers of which idls are missing -64 """ -65 missing = [] -66 for c in che: -67 if c not in idl: -68 missing.append(c) -69 # print missing configurations such that it can directly be parsed to slurm terminal -70 if not (len(missing) == 0): -71 print(len(missing), "configs missing") -72 miss_str = str(missing[0]) -73 for i in missing[1:]: -74 miss_str += "," + str(i) -75 print(miss_str) -76 return miss_str +52def check_idl(idl, che): +53 """Checks if list of configurations is contained in an idl +54 +55 Parameters +56 ---------- +57 idl : range or list +58 idl of the current replicum +59 che : list +60 list of configurations to be checked against +61 +62 Returns +63 ------- +64 miss_str : str +65 string with integers of which idls are missing +66 """ +67 missing = [] +68 for c in che: +69 if c not in idl: +70 missing.append(c) +71 # print missing configurations such that it can directly be parsed to slurm terminal +72 if not (len(missing) == 0): +73 print(len(missing), "configs missing") +74 miss_str = str(missing[0]) +75 for i in missing[1:]: +76 miss_str += "," + str(i) +77 print(miss_str) +78 return miss_str