def test_thin(): import operator def betterthan(l, r): return l[0] == r[0] and len(l) > len(r) l = ["abcd", "a", "ab", "abc", "b", "bc"] r = g.thin(l, betterthan, lambda x: x) eq_(r,["abcd", "bc"]) l = ['a1', 'b1', 'c1', 'a', 'd', 'b'] r = g.thin(l, betterthan) eq_(set(r), set(['a1', 'b1', 'c1', 'd']))
print "sought:", soughtchord candidates += [(s, combo, result, tonicstring)] candgrips += [(s, Grip(combo, [int(x != None) for x in result], neck, tonicstring).normalize())] neck.allup() # sys.exit(0) # candidates.sort(cmp=lambda x,y: x[0] - y[0]) candgrips = g.uniqify(candgrips, lambda x: x[1]) candgrips = g.thin(candgrips, Grip.superset_of, lambda x: x[1]) for c in candgrips: print str(c[1]), '\n' sys.exit(1) redundant_grips = [] print "Done searching.\n", '-'*40, "\nCandidates:" pprint(candidates) # pprint(candgrips) # sys.exit(1) def clean(l, pred): todelete = []