14e7753441932b61c5eb061dcc5c18a2f2ae4721,gb/hypergraph/sql.py,,nthperm,#Any#Any#,27
Before Change
def nthperm(li, n):
n -= 1
s = len(li)
res = []
for x in range(s-1, -1, -1):
f = math.factorial(x)
d = n / f
n -= d * f
res.append(li[d])
del(li[d])
return res
def do_with_edge_permutations(edge, f):
After Change
// TODO: make this more efficient
indices = [i for i in range(len(li))]
pos = 0
for perm in itertools.permutations(indices):
if pos >= n:
indices = perm
break
pos += 1
return [li[indices[i]] for i in range(len(li))]
def do_with_edge_permutations(edge, f):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 8
Instances
Project Name: graphbrain/graphbrain
Commit Name: 14e7753441932b61c5eb061dcc5c18a2f2ae4721
Time: 2016-07-29
Author: telmo@telmomenezes.net
File Name: gb/hypergraph/sql.py
Class Name:
Method Name: nthperm
Project Name: markovmodel/PyEMMA
Commit Name: 4046c198f9a4a9d209926aa8cabbda0d962f7e7a
Time: 2018-01-09
Author: m.scherer@fu-berlin.de
File Name: pyemma/_base/model.py
Class Name: Model
Method Name: __my_setstate__
Project Name: cmu-db/ottertune
Commit Name: 21971e673fabe25d3e7da6712f80222760516113
Time: 2020-02-26
Author: bohanzhang95@gmail.com
File Name: server/website/website/tasks/async_tasks.py
Class Name:
Method Name: clean_metric_data