/usr/lib/python2.7/dist-packages/brial/rank.py is in python-brial 1.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | def input_signals(p):
return list((p + p.lex_lead()).vars_as_monomial().variables())
def output_signal(p):
return next(iter(p.lex_lead().variables()))
def rank(data):
parents = dict()
res = dict()
for p in data:
# print p, output_signal(p)
out = output_signal(p)
parents.setdefault(out, [])
for v in input_signals(p):
parents.setdefault(v, []).append(out)
def do_rank(v):
if v in res:
return res[v]
my_res = res[v] = max([do_rank(p) + 1 for p in parents[v]] + [0])
return my_res
for v in parents.keys():
do_rank(v)
return res
|