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:
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.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):
......@@ -61,6 +62,11 @@ class Code:
code = code.replace(old, new)
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):
code = remove_comments(self.code)
index = code.find(bit_of_code)
......
......@@ -577,34 +577,94 @@ def exist_path_dico(A, B, dico):
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):
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])
edges = remove_edges_with_node(dico["edges"], rest_of_R)
exists, _ = exist_path(n, r, edges)
if(exists):
return True
return False
try:
temp = path_exists[n][r][str(rest_of_R)]
return temp
except:
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):
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])
edges = remove_edges_with_node(dico["edges"], rest_of_R)
exists, _ = exist_path(r, n, edges)
if(exists):
return True
return False
try:
temp = path_exists[r][n][str(rest_of_R)]
return temp
except:
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
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
try:
temp = dico_rSucc[n]
except:
dico_rSucc[n] = {}
union_set = set(R).union(set(outputs))
try:
temp = dico_rSucc[n][str(union_set)]
return temp
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):
tab = []
......@@ -612,18 +672,37 @@ def rSuccM(M, dico, R, outputs):
tab += rSucc(n, dico, R, outputs)
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
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
try:
temp = dico_rPred[n]
except:
dico_rPred[n] = {}
union_set = set(R).union(set(inputs))
try:
temp = dico_rPred[n][str(union_set)]
return temp
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):
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