Skip to content
Snippets Groups Projects
Commit b55e7a50 authored by George Marchment's avatar George Marchment
Browse files

optimised the implementation of the user view

parent 0b8e77c8
No related branches found
No related tags found
No related merge requests found
Pipeline #14444 failed with stage
in 2 minutes and 29 seconds
...@@ -22,6 +22,7 @@ class Code: ...@@ -22,6 +22,7 @@ class Code:
self.code_wo_comments = self.code_wo_comments.replace("||", "$OR$") self.code_wo_comments = self.code_wo_comments.replace("||", "$OR$")
self.code_wo_comments = self.turn_single_condition_into_multiline(self.code_wo_comments) self.code_wo_comments = self.turn_single_condition_into_multiline(self.code_wo_comments)
self.code_wo_comments = self.rewrite_ternary_operation_to_normal_condition(self.code_wo_comments) self.code_wo_comments = self.rewrite_ternary_operation_to_normal_condition(self.code_wo_comments)
self.code_wo_comments = self.rewrite_jump_dot(self.code_wo_comments)
def check_its_nextflow(self): def check_its_nextflow(self):
...@@ -61,6 +62,11 @@ class Code: ...@@ -61,6 +62,11 @@ class Code:
code = code.replace(old, new) code = code.replace(old, new)
return code return code
def rewrite_jump_dot(self, code):
pattern = r"\n *\."
code = re.sub(pattern, '.', code)
return code
def get_line(self, bit_of_code): def get_line(self, bit_of_code):
code = remove_comments(self.code) code = remove_comments(self.code)
index = code.find(bit_of_code) index = code.find(bit_of_code)
......
...@@ -577,34 +577,94 @@ def exist_path_dico(A, B, dico): ...@@ -577,34 +577,94 @@ def exist_path_dico(A, B, dico):
return exists, visited return exists, visited
#def nr_path_succ(n, r, dico, R):
# rest_of_R = set(R)-set([r])
# edges = remove_edges_with_node(dico["edges"], rest_of_R)
# exists, _ = exist_path(n, r, edges)
# if(exists):
# return True
# return False
path_exists = {}
def nr_path_succ(n, r, dico, R): def nr_path_succ(n, r, dico, R):
try:
temp = path_exists[n]
except:
path_exists[n] = {}
try:
temp = path_exists[n][r]
except:
path_exists[n][r] = {}
rest_of_R = set(R)-set([r]) rest_of_R = set(R)-set([r])
edges = remove_edges_with_node(dico["edges"], rest_of_R) try:
exists, _ = exist_path(n, r, edges) temp = path_exists[n][r][str(rest_of_R)]
if(exists): return temp
return True except:
return False edges = remove_edges_with_node(dico["edges"], rest_of_R)
exists, _ = exist_path(n, r, edges)
path_exists[n][r][str(rest_of_R)] = exists
return exists
#def nr_path_pred(r, n, dico, R):
# rest_of_R = set(R)-set([r])
# edges = remove_edges_with_node(dico["edges"], rest_of_R)
# exists, _ = exist_path(r, n, edges)
# if(exists):
# return True
# return False
def nr_path_pred(r, n, dico, R): def nr_path_pred(r, n, dico, R):
try:
temp = path_exists[r]
except:
path_exists[r] = {}
try:
temp = path_exists[r][n]
except:
path_exists[r][n] = {}
rest_of_R = set(R)-set([r]) rest_of_R = set(R)-set([r])
edges = remove_edges_with_node(dico["edges"], rest_of_R) try:
exists, _ = exist_path(r, n, edges) temp = path_exists[r][n][str(rest_of_R)]
if(exists): return temp
return True except:
return False edges = remove_edges_with_node(dico["edges"], rest_of_R)
exists, _ = exist_path(r, n, edges)
path_exists[r][n][str(rest_of_R)] = exists
return exists
##Added a dico so it knows what it's already searched
#dico_rSucc = {}
#def rSucc(n, dico, R, outputs):
# #try:
# # tab = dico_rSucc[n]
# #except:
# tab = []
# for r in set(R).union(set(outputs)):
# if(nr_path_succ(n, r, dico, R+list(outputs))):
# tab.append(r)
# dico_rSucc[n] = tab
# return tab
#Added a dico so it knows what it's already searched #Added a dico so it knows what it's already searched
dico_rSucc = {} dico_rSucc = {}
def rSucc(n, dico, R, outputs): def rSucc(n, dico, R, outputs):
#try: try:
# tab = dico_rSucc[n] temp = dico_rSucc[n]
#except: except:
tab = [] dico_rSucc[n] = {}
for r in set(R).union(set(outputs)): union_set = set(R).union(set(outputs))
if(nr_path_succ(n, r, dico, R+list(outputs))): try:
tab.append(r) temp = dico_rSucc[n][str(union_set)]
dico_rSucc[n] = tab return temp
return tab except:
tab = []
for r in union_set:
if(nr_path_succ(n, r, dico, R+list(outputs))):
tab.append(r)
dico_rSucc[n][str(union_set)] = tab
return tab
def rSuccM(M, dico, R, outputs): def rSuccM(M, dico, R, outputs):
tab = [] tab = []
...@@ -612,18 +672,37 @@ def rSuccM(M, dico, R, outputs): ...@@ -612,18 +672,37 @@ def rSuccM(M, dico, R, outputs):
tab += rSucc(n, dico, R, outputs) tab += rSucc(n, dico, R, outputs)
return list(set(tab)) return list(set(tab))
#Added a dico so it knows what it's already searched
#dico_rPred = {}
#def rPred(n, dico, R, inputs):
# #try:
# # tab = dico_rPred[n]
# #except:
# tab = []
# for r in set(R).union(set(inputs)):
# if(nr_path_pred(r, n, dico, R+list(inputs))):
# tab.append(r)
# dico_rPred[n] = tab
# return tab
#Added a dico so it knows what it's already searched #Added a dico so it knows what it's already searched
dico_rPred = {} dico_rPred = {}
def rPred(n, dico, R, inputs): def rPred(n, dico, R, inputs):
#try: try:
# tab = dico_rPred[n] temp = dico_rPred[n]
#except: except:
tab = [] dico_rPred[n] = {}
for r in set(R).union(set(inputs)): union_set = set(R).union(set(inputs))
if(nr_path_pred(r, n, dico, R+list(inputs))): try:
tab.append(r) temp = dico_rPred[n][str(union_set)]
dico_rPred[n] = tab return temp
return tab except:
tab = []
for r in union_set:
if(nr_path_pred(r, n, dico, R+list(inputs))):
tab.append(r)
dico_rPred[n][str(union_set)] = tab
return tab
def rPredM(M, dico, R, inputs): def rPredM(M, dico, R, inputs):
tab = [] tab = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment