def allbpms(bpm, maxdiff=5, minbpm=60, maxbpm=190): doubles = poweroftwos(bpm) bpms = [] for dbl in doubles: bpms.append([dbl - x for x in range(1, maxdiff + 1)]) bpms.append([dbl]) bpms.append([dbl + x for x in range(1, maxdiff + 1)]) isgood = partial(goodbpm, minbpm=minbpm, maxbpm=maxbpm) return filter(isgood, flatten(bpms))
def components(c): """Get component characters of the 汉字 c. We ignore components that don't have standalone definitions. e.g.: 国 -> 囗玉""" return [x[0] for x in unique(flatten(cl.getDecompositionEntries(c))) if type(x) == tuple]
def parsedelta(ipordns_gametype): try: x, y = zip(*[(x[0], x[1]) for x in unique(flatten(filter(None, ipordns_gametype)))]) return (x, y) except ValueError: # Empty list return ([], [])